From fa17c1573f88c24a8e7d7d6dce67ad0d27486084 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 21 Nov 2022 12:27:28 +0100 Subject: 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 --- modules/luci-lua-runtime/luasrc/dispatcher.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'modules/luci-lua-runtime/luasrc/dispatcher.lua') 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 { -- cgit v1.2.3