projects
/
project
/
luci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
10f21f5
)
libs/web: dispatcher: fix access to template properties in attr() and ifattr() helper...
author
Jo-Philipp Wich
<jow@openwrt.org>
Sun, 30 Oct 2011 15:00:54 +0000
(15:00 +0000)
committer
Jo-Philipp Wich
<jow@openwrt.org>
Sun, 30 Oct 2011 15:00:54 +0000
(15:00 +0000)
libs/web/luasrc/dispatcher.lua
patch
|
blob
|
history
diff --git
a/libs/web/luasrc/dispatcher.lua
b/libs/web/luasrc/dispatcher.lua
index
fa78b2f
..
911f2f4
100644
(file)
--- 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
assert(media, "No valid theme found")
end
- local function ifattr(cond, key, val)
+ local function
_
ifattr(cond, key, val)
if cond then
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])
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
or "" ))
)
else
@@
-308,8
+310,8
@@
function dispatch(request)
media = media;
theme = fs.basename(media);
resource = luci.config.main.resourcebase;
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()
}, {__index=function(table, key)
if key == "controller" then
return build_url()