diff options
-rw-r--r-- | libs/web/luasrc/template.lua | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libs/web/luasrc/template.lua b/libs/web/luasrc/template.lua index 907403fcbb..d49bceac7d 100644 --- a/libs/web/luasrc/template.lua +++ b/libs/web/luasrc/template.lua @@ -144,6 +144,7 @@ setmetatable(Template.cache, {__mode = "v"}) -- Constructor - Reads and compiles the template on-demand function Template.__init__(self, name) self.template = self.cache[name] + self.name = name -- Create a new namespace for this template self.viewns = {} @@ -226,7 +227,10 @@ function Template.render(self, scope) luci.util.updfenv(self.template, self.viewns) -- Now finally render the thing - self.template() + local stat, err = luci.util.copcall(self.template) + if not stat then + error("Error in template %s: %s" % {self.name, err}) + end -- Reset environment setfenv(self.template, oldfenv) |