summaryrefslogtreecommitdiffhomepage
path: root/src/ffluci/template.lua
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-03-24 15:39:32 +0000
committerSteven Barth <steven@midlink.org>2008-03-24 15:39:32 +0000
commit06a385370c630a2e57412caf3a67ac77cc0e1b49 (patch)
treec93440d4623d17fa4094e9abe253b910edabdb5c /src/ffluci/template.lua
parentef01ff75db17f23a90757cf473778cfefe1ad120 (diff)
* CBI: updates
* UCI: Introduced Session class, supporting different change file paths * util: introduced sessionid() function * general: Changed several error messages to OS native ones
Diffstat (limited to 'src/ffluci/template.lua')
-rw-r--r--src/ffluci/template.lua18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/ffluci/template.lua b/src/ffluci/template.lua
index 18265a4a16..17f36194fd 100644
--- a/src/ffluci/template.lua
+++ b/src/ffluci/template.lua
@@ -128,7 +128,7 @@ function render(name, scope, ...)
scope = scope or getfenv(2)
local s, t = pcall(Template, name)
if not s then
- error("Unable to load template: " .. name)
+ error(t)
else
t:render(scope, ...)
end
@@ -165,7 +165,8 @@ function Template.__init__(self, name)
-- Compile and build
local sourcefile = viewdir .. name .. ".htm"
- local compiledfile = viewdir .. name .. ".lua"
+ local compiledfile = viewdir .. name .. ".lua"
+ local err
if compiler_mode == "file" then
local tplmt = ffluci.fs.mtime(sourcefile)
@@ -176,25 +177,22 @@ function Template.__init__(self, name)
or (not (commt == nil) and not (tplmt == nil) and commt < tplmt) then
local compiled = compile(ffluci.fs.readfile(sourcefile))
ffluci.fs.writefile(compiledfile, compiled)
- self.template = loadstring(compiled)
+ self.template, err = loadstring(compiled)
else
- self.template = loadfile(compiledfile)
+ self.template, err = loadfile(compiledfile)
end
elseif compiler_mode == "none" then
- self.template = loadfile(self.compiledfile)
+ self.template, err = loadfile(self.compiledfile)
elseif compiler_mode == "memory" then
- self.template = loadstring(compile(ffluci.fs.readfile(sourcefile)))
+ self.template, err = loadstring(compile(ffluci.fs.readfile(sourcefile)))
- else
- error("Invalid compiler mode: " .. compiler_mode)
-
end
-- If we have no valid template throw error, otherwise cache the template
if not self.template then
- error("Unable to load template: " .. name)
+ error(err)
else
self.cache[name] = self.template
end