Documentation ¶
Overview ¶
Package template implements template functionality for lua.
Example (Package) ¶
state := lua.NewState() Preload(state) inspect.Preload(state) source := ` local template = require("template") local mustache, err = template.choose("mustache") local values = {name="world"} print( mustache:render("Hello {{name}}!", values) ) -- mustache:render_file(filename values) local values = {data = {"one", "two"}} print( mustache:render("{{#data}} {{.}} {{/data}}", values) ) ` if err := state.DoString(source); err != nil { log.Fatal(err.Error()) }
Output: Hello world! one two
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Preload ¶
Preload adds template to the given Lua state's package.preload table. After it has been preloaded, it can be loaded using require:
local template = require("template")
func RegisterTemplateEngine ¶
func RegisterTemplateEngine(driver string, i luaTemplateEngine)
RegisterTemplateEngine(): register template engine
func RenderFile ¶
RenderFile(): lua template_ud:render(string, values) returns (string, err)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.