summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-11-22 09:41:31 +0100
committerJo-Philipp Wich <jo@mein.io>2022-11-22 09:41:31 +0100
commita5d21dadbd5f856c7c941a7abd1a8442f8a91de8 (patch)
tree4e016acee8eae81679e78bb37ec4180d269abbe1
parent7c3705bb0f351e1d107c38e21bf7d0480824baa0 (diff)
luci-base: fix rendering ucode templates from `template` target
A previous commit inadvertently broke support for rendering ucode templates from the `template` dispatcher target. Fixes: #6111 Fixes: fa17c1573f ("luci-base, luci-lua-runtime: adjust Lua template environment") Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--modules/luci-base/ucode/dispatcher.uc9
-rw-r--r--modules/luci-base/ucode/runtime.uc4
2 files changed, 10 insertions, 3 deletions
diff --git a/modules/luci-base/ucode/dispatcher.uc b/modules/luci-base/ucode/dispatcher.uc
index 0644a756c2..50201be0f4 100644
--- a/modules/luci-base/ucode/dispatcher.uc
+++ b/modules/luci-base/ucode/dispatcher.uc
@@ -774,9 +774,12 @@ function render_action(fn) {
function run_action(request_path, lang, tree, resolved, action) {
switch (action?.type) {
case 'template':
- render_action(() => {
- runtime.call('luci.dispatcher', 'render_lua_template', action.path);
- });
+ if (runtime.is_ucode_template(action.path))
+ runtime.render_ucode(action.path);
+ else
+ render_action(() => {
+ runtime.call('luci.dispatcher', 'render_lua_template', action.path);
+ });
break;
case 'view':
diff --git a/modules/luci-base/ucode/runtime.uc b/modules/luci-base/ucode/runtime.uc
index da73d13fe4..89e396d468 100644
--- a/modules/luci-base/ucode/runtime.uc
+++ b/modules/luci-base/ucode/runtime.uc
@@ -61,6 +61,10 @@ const Class = {
return this.L;
},
+ is_ucode_template: function(path) {
+ return access(`${template_directory}/${path}.ut`);
+ },
+
render_ucode: function(path, scope) {
let tmplfunc = loadfile(path, { raw_mode: false });