summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2011-10-30 15:00:54 +0000
committerJo-Philipp Wich <jow@openwrt.org>2011-10-30 15:00:54 +0000
commit96f494f4bae187c700e9d9ad77f77b4085908e9a (patch)
treee73c9185ad886b8d38d00dd7f4516df39fc3f0f4
parent10f21f5c7309f7ea105a2f20ae769c92de9eb325 (diff)
libs/web: dispatcher: fix access to template properties in attr() and ifattr() helpers (#10317)
-rw-r--r--libs/web/luasrc/dispatcher.lua10
1 files changed, 6 insertions, 4 deletions
diff --git a/libs/web/luasrc/dispatcher.lua b/libs/web/luasrc/dispatcher.lua
index fa78b2f65..911f2f4e9 100644
--- a/libs/web/luasrc/dispatcher.lua
+++ b/libs/web/luasrc/dispatcher.lua
@@ -284,13 +284,15 @@ function dispatch(request)
assert(media, "No valid theme found")
end
- local function ifattr(cond, key, val)
+ local function _ifattr(cond, key, val)
if cond then
- local env = getfenv(1)
+ local env = getfenv(3)
+ local scope = (type(env.self) == "table") and env.self
return string.format(
' %s="%s"', tostring(key),
luci.util.pcdata(tostring( val
or (type(env[key]) ~= "function" and env[key])
+ or (scope and type(scope[key]) ~= "function" and scope[key])
or "" ))
)
else
@@ -308,8 +310,8 @@ function dispatch(request)
media = media;
theme = fs.basename(media);
resource = luci.config.main.resourcebase;
- ifattr = ifattr;
- attr = function(...) return ifattr(true, ...) end
+ ifattr = function(...) return _ifattr(...) end;
+ attr = function(...) return _ifattr(true, ...) end;
}, {__index=function(table, key)
if key == "controller" then
return build_url()