TemplateEngine
(in ./Carbon/TemplateEngine.lua)
Templating engine targeted at metaprogramming.
Templates can use the _ (single underscore) function to output a string, and the RenderPartial function to render a partial by name.
Most safe Lua functions are exposed to templates.
Methods
class public TemplateEngine:New()
Returns TemplateEngine
class public TemplateEngine:PlacementNew(TemplateEngine? out)
Returns TemplateEngine
object public TemplateEngine:Init()
Returns void
Creates or initializes a TemplateEngine object.
object public TemplateEngine:Render(string document, [table data, unumber level])
Returns string
- required
document: The template-enabled document to render. - optional
data: The data to pass to the template. - optional
level: What level of templates to execute.
Compiles and executes a template-enabled document with the given data.
object public TemplateEngine:Compile(string document, [unumber level])
Returns string
- required
document: The document containing templates to compile. - optional
level: The level of template to use, defaults to 0.
Takes the contents of a templated document and compiles it to a piece of Lua code.
object public TemplateEngine:Execute(string compiled, [table data])
Returns string
- required
compiled: A piece of Lua code that was compiled from a templated document. - optional
data: Data to pass into the template.
Executes an already-compiled Soquid document with the given data and returns the result.
object public TemplateEngine:AddPartial(string name, string document, [unumber level])
Returns void
- required
name: The name of the partial document. - required
document: The body of the partial document. - optional
level: The level of templates used in the document.
Adds a partial document with a given name and body.
Properties
[none]