precompile the jade partial views

This commit is contained in:
Henry Oswald 2016-08-23 15:31:09 +01:00
parent 130fece0f6
commit d3ebdb64b2

View file

@ -25,14 +25,14 @@ module.exports = Modules =
for module in @modules for module in @modules
for view, partial of module.viewIncludes or {} for view, partial of module.viewIncludes or {}
@viewIncludes[view] ||= [] @viewIncludes[view] ||= []
@viewIncludes[view].push fs.readFileSync(Path.join(MODULE_BASE_PATH, module.name, "app/views", partial + ".jade")) @viewIncludes[view].push jade.compile(fs.readFileSync(Path.join(MODULE_BASE_PATH, module.name, "app/views", partial + ".jade")), doctype: "html")
moduleIncludes: (view, locals) -> moduleIncludes: (view, locals) ->
partials = Modules.viewIncludes[view] or [] compiledPartials = Modules.viewIncludes[view] or []
html = "" html = ""
for partial in partials for compiledPartial in compiledPartials
compiler = jade.compile(partial, doctype: "html") d = new Date()
html += compiler(locals) html += compiledPartial(locals)
return html return html
moduleIncludesAvailable: (view) -> moduleIncludesAvailable: (view) ->