Lines Matching full:template
1 -- From lua-resty-template (modified to remove external dependencies)
100 return t.context[k] or t.template[k] or _G[k]
104 return t.context[k] or t.template[k] or _ENV[k]
156 local function load_view(template)
159 local path, root = view, template.root
177 local function loader(template)
179 return assert(load(view, nil, nil, setmetatable({ template = template }, VIEW_ENV)))
195 local function new(template, safe)
196 template = template or newtab(0, 26)
198 template._VERSION = "2.0"
199 template.cache = {}
200 template.load = load_view(template)
201 template.load_file = load_file(template.load)
202 template.load_string = load_string(template.load)
203 template.print = write
205 local load_chunk = loader(template)
215 function template.visit(func)
224 function template.caching(enable)
229 function template.output(s)
231 if type(s) == "function" then return template.output(s()) end
235 function template.escape(s, c)
240 return template.output(s)
243 function template.new(view, layout)
257 context.view = template.process(view, context)
265 context.view = template.process(view, context)
274 context.view = template.process(view, context)
275 template.render(layout, context)
280 context.view = template.process(view, context)
281 return template.process(layout, context)
286 return template.render(view, context or self)
289 return template.process(view, context or self)
326 function template.precompile(view, path, strip, plain)
327 local chunk = dump(template.compile(view, nil, plain), strip ~= false)
336 function template.precompile_string(view, path, strip)
337 return template.precompile(view, path, strip, true)
340 function template.precompile_file(view, path, strip)
341 return template.precompile(view, path, strip, false)
344 function template.compile(view, cache_key, plain)
345 assert(view, "view was not provided for template.compile(view, cache_key, plain)")
347 return load_chunk(template.parse(view, plain)), false
350 local cache = template.cache
352 local func = load_chunk(template.parse(view, plain))
357 function template.compile_file(view, cache_key)
358 return template.compile(view, cache_key, false)
361 function template.compile_string(view, cache_key)
362 return template.compile(view, cache_key, true)
365 function template.parse(view, plain)
366 assert(view, "view was not provided for template.parse(view, plain)")
368 view = template.load(view, plain)
375 local function include(v, c) return template.process(v, c or context) end
394 c[j] = "___[#___+1]=template.escape("
414 c[j] = "___[#___+1]=template.output("
590 function template.parse_file(view)
591 return template.parse(view, false)
594 function template.parse_string(view)
595 return template.parse(view, true)
598 function template.process(view, context, cache_key, plain)
599 assert(view, "view was not provided for template.process(view, context, cache_key, plain)")
600 return template.compile(view, cache_key, plain)(context)
603 function template.process_file(view, context, cache_key)
604 assert(view, "view was not provided for template.process_file(view, context, cache_key)")
605 return template.compile(view, cache_key, false)(context)
608 function template.process_string(view, context, cache_key)
609 assert(view, "view was not provided for template.process_string(view, context, cache_key)")
610 return template.compile(view, cache_key, true)(context)
613 function template.render(view, context, cache_key, plain)
614 assert(view, "view was not provided for template.render(view, context, cache_key, plain)")
615 template.print(template.process(view, context, cache_key, plain))
618 function template.render_file(view, context, cache_key)
619 assert(view, "view was not provided for template.render_file(view, context, cache_key)")
620 template.render(view, context, cache_key, false)
623 function template.render_string(view, context, cache_key)
624 assert(view, "view was not provided for template.render_string(view, context, cache_key)")
625 template.render(view, context, cache_key, true)
631 if type(template[k]) == "function" then
633 local ok, a, b = pcall(template[k], ...)
640 return template[k]
643 template[k] = v
648 return template