summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-lua-runtime
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-11-21 12:27:28 +0100
committerJo-Philipp Wich <jo@mein.io>2022-11-21 12:27:28 +0100
commitfa17c1573f88c24a8e7d7d6dce67ad0d27486084 (patch)
tree7b5ac71ef037872a684b61d9eb8ed32aa4f57056 /modules/luci-lua-runtime
parent08ae8d40a939654d2e4a1774853c5c5683b12268 (diff)
luci-base, luci-lua-runtime: adjust Lua template environment
To maintain full compatibility with the old Lua runtime, templates rendered from a menu `template()` action must implicitly inherit the `luci.dispatcher` namespace as scope while other indirectly included templates must not. Fixes: #6105 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-lua-runtime')
-rw-r--r--modules/luci-lua-runtime/luasrc/dispatcher.lua6
-rw-r--r--modules/luci-lua-runtime/luasrc/template.lua2
2 files changed, 7 insertions, 1 deletions
diff --git a/modules/luci-lua-runtime/luasrc/dispatcher.lua b/modules/luci-lua-runtime/luasrc/dispatcher.lua
index 608b9b6674..93f7f8949b 100644
--- a/modules/luci-lua-runtime/luasrc/dispatcher.lua
+++ b/modules/luci-lua-runtime/luasrc/dispatcher.lua
@@ -354,6 +354,12 @@ function invoke_form_action(model, ...)
_G.L.include("footer")
end
+function render_lua_template(path)
+ local tpl = require "luci.template"
+
+ tpl.render(path, getfenv(1))
+end
+
function call(name, ...)
return {
diff --git a/modules/luci-lua-runtime/luasrc/template.lua b/modules/luci-lua-runtime/luasrc/template.lua
index 84fb8bb338..b6b9af0bad 100644
--- a/modules/luci-lua-runtime/luasrc/template.lua
+++ b/modules/luci-lua-runtime/luasrc/template.lua
@@ -121,7 +121,7 @@ context.viewns = setmetatable({
elseif key == "resource" then
return L.config.main.resourcebase
else
- return rawget(tbl, key) or disp[key] or _G[key] or L[key]
+ return rawget(tbl, key) or _G[key] or L[key]
end
end})