summaryrefslogtreecommitdiffhomepage
path: root/libs/web/luasrc/template.lua
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-07-29 20:32:02 +0000
committerSteven Barth <steven@midlink.org>2008-07-29 20:32:02 +0000
commit5b43543226fa29dc7d899e9fc82f0179aefcb56b (patch)
tree08ced0102f805fd74fd83088deda0a3d9878d9a8 /libs/web/luasrc/template.lua
parenta478f25f513cb26e671f8a1c204bafb9b66cfabf (diff)
libs/web: Small improvements, added inline documentation
Diffstat (limited to 'libs/web/luasrc/template.lua')
-rw-r--r--libs/web/luasrc/template.lua12
1 files changed, 9 insertions, 3 deletions
diff --git a/libs/web/luasrc/template.lua b/libs/web/luasrc/template.lua
index 12b80bec8..17e1daad7 100644
--- a/libs/web/luasrc/template.lua
+++ b/libs/web/luasrc/template.lua
@@ -23,6 +23,8 @@ See the License for the specific language governing permissions and
limitations under the License.
]]--
+
+--- LuCI template library.
module("luci.template", package.seeall)
require("luci.config")
@@ -50,9 +52,11 @@ viewns = {
include = function(name) Template(name):render(getfenv(2)) end,
}
--- Compiles a given template into an executable Lua module
+--- Manually compile a given template into an executable Lua function
+-- @param template LuCI template
+-- @return Lua template function
function compile(template)
- -- Search all <% %> expressions (remember: Lua table indexes begin with #1)
+ -- Search all <% %> expressions
local function expr_add(ws1, skip1, command, skip2, ws2)
table.insert(expr, command)
return ( #skip1 > 0 and "" or ws1 ) ..
@@ -114,7 +118,9 @@ function compile(template)
return loadstring(template)
end
--- Oldstyle render shortcut
+--- Render a certain template.
+-- @param name Template name
+-- @param scope Scope to assign to template
function render(name, scope, ...)
scope = scope or getfenv(2)
local s, t = luci.util.copcall(Template, name)