0001 import Stencil 0002 import PathKit 0003 0004 protocol View { 0005 init(_ path: String, _ context: [String: Any]?) 0006 func render() -> String 0007 } 0008 0009 struct StencilView{ 0010 var template: Template? 0011 var context
Controller.swift:89 let body = StencilView(template).render()Controller.swift:96 body = StencilView(template, obj.renderableAttributes()).render()Controller.swift:98 body = StencilView(template).render()Controller.swift:105 body = StencilView(template, context).render(): [String: Any]? 0012 0013 init(_ path: String, _ context: [String: Any]? = nil) { 0014 self.context = context 0015 0016 var templatePath = path.characters.split{$0 == "/"}.map(String.init) 0017 let templateName = templatePath.removeLast() 0018 0019 let appPath = Path(SwiftonConfig.viewsDirectory) 0020 let paths = [appPath + templatePath.joinWithSeparator("/")] 0021 let templateLoader = TemplateLoader(paths: paths) 0022 self.template = templateLoader.loadTemplate(templateName + ".html.stencil") 0023 } 0024 0025 func render() -> String { 0026 guard template != nil else { return "Template Not Found" } 0027 guard context != nil else { return try! template!.render() } 0028 return try! template!.render(Context(dictionary: context!)) 0029 } 0030 } 0031 0032 struct JSONView
View.swift:14 self.context = contextView.swift:27 guard context != nil else { return try! template!.render() }{ 0033 var context
Controller.swift:112 body = JSONView(obj.renderableJSONAttributes()).render()Controller.swift:121 body = JSONView(context).render(): [String: Any]? 0034 0035 init(_ context: [String: Any]? = nil) { 0036 self.context = context 0037 } 0038 0039 func render() -> String { 0040 guard context != nil else { return "" } 0041 let json = context!.toJSON() 0042 return json! 0043 } 0044 } 0045 0046 0047
View.swift:36 self.context = contextView.swift:40 guard context != nil else { return "" }View.swift:41 let json = context!.toJSON()