Add table (pseudo-)loader
This commit is contained in:
parent
2ec8932696
commit
1bf67ea009
3 changed files with 14 additions and 0 deletions
|
@ -22,6 +22,7 @@ build = {
|
||||||
["glass.moonhtml_cosmo"] = "glass/moonhtml_cosmo.lua",
|
["glass.moonhtml_cosmo"] = "glass/moonhtml_cosmo.lua",
|
||||||
["glass.raw"] = "glass/raw.lua",
|
["glass.raw"] = "glass/raw.lua",
|
||||||
["glass.skooma"] = "glass/skooma.lua",
|
["glass.skooma"] = "glass/skooma.lua",
|
||||||
|
["glass.table"] = "glass/table.lua",
|
||||||
["glass.yaml"] = "glass/yaml.lua"
|
["glass.yaml"] = "glass/yaml.lua"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
12
glass/table.lua
Normal file
12
glass/table.lua
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
--- Pseudo-loader for Lua tables
|
||||||
|
-- Can be used to "overlay" static values over or under other configuration sources.
|
||||||
|
-- @module glass.table
|
||||||
|
|
||||||
|
--- Returns a (pseudo-)loader function from a given Table
|
||||||
|
-- @tparam table table The table in which to look up valuse
|
||||||
|
-- @treturn function A loader function to be used with `glass.bind`
|
||||||
|
return function(input)
|
||||||
|
return function(name)
|
||||||
|
return input[name:match("[^/].+$")]
|
||||||
|
end
|
||||||
|
end
|
|
@ -33,6 +33,7 @@ Glass offers the following loaders out of the box:
|
||||||
* `moonhtml` loads a MoonHTML template and returns it as a function.
|
* `moonhtml` loads a MoonHTML template and returns it as a function.
|
||||||
* `readfile` loads a file as a string.
|
* `readfile` loads a file as a string.
|
||||||
* `skooma` loads a skooma template and returns it as a function.
|
* `skooma` loads a skooma template and returns it as a function.
|
||||||
|
* `table` looks up values in a Lua table
|
||||||
* `yaml` loads a YAML file as a Lua table.
|
* `yaml` loads a YAML file as a Lua table.
|
||||||
|
|
||||||
\* For easier interoperability with other template loaders, the `discount` loader returns a static function which can be called to return the generated HTML. The markdown file is only parsed the first time.
|
\* For easier interoperability with other template loaders, the `discount` loader returns a static function which can be called to return the generated HTML. The markdown file is only parsed the first time.
|
||||||
|
|
Loading…
Reference in a new issue