summaryrefslogtreecommitdiffhomepage
path: root/libs/cbi/luasrc/cbi.lua
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2008-07-15 17:27:58 +0000
committerJo-Philipp Wich <jow@openwrt.org>2008-07-15 17:27:58 +0000
commit05d3bf06b4ae6f07ed1c55fd1f7b4e97cb0e2d3d (patch)
treec113e7631018a7f9a46098419fa9b894fa6d0477 /libs/cbi/luasrc/cbi.lua
parent8bb8b7c09cee818246312a637d846be491e171d3 (diff)
* luci/libs/cbi: various template cleanups
Diffstat (limited to 'libs/cbi/luasrc/cbi.lua')
-rw-r--r--libs/cbi/luasrc/cbi.lua26
1 files changed, 22 insertions, 4 deletions
diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua
index 7370a04c46..6123e273b6 100644
--- a/libs/cbi/luasrc/cbi.lua
+++ b/libs/cbi/luasrc/cbi.lua
@@ -316,7 +316,7 @@ NamedSection = class(AbstractSection)
function NamedSection.__init__(self, map, section, type, ...)
AbstractSection.__init__(self, map, type, ...)
Node._i18n(self, map.config, section, nil, ...)
-
+
self.template = "cbi/nsection"
self.section = section
self.addremove = false
@@ -378,7 +378,7 @@ function TypedSection.cfgsections(self)
function (section)
if self:checkscope(section[".name"]) then
table.insert(sections, section[".name"])
- end
+ end
end)
return sections
@@ -554,7 +554,25 @@ function AbstractValue.render(self, s, scope)
if not self.optional or self:cfgvalue(s) or self:formcreated(s) then
scope = scope or {}
scope.section = s
-
+ scope.cbid = "cbid." .. self.config ..
+ "." .. s ..
+ "." .. self.option
+
+ scope.ifattr = function(cond,key,val)
+ if cond then
+ return string.format(
+ ' %s="%s"', tostring(key),
+ tostring( val or scope[key] or self[key] or "" )
+ )
+ else
+ return ''
+ end
+ end
+
+ scope.attr = function(...)
+ return scope.ifattr( true, ... )
+ end
+
Node.render(self, scope)
end
end
@@ -731,7 +749,7 @@ function MultiValue.valuelist(self, section)
end
function MultiValue.validate(self, val)
- val = (type(val) == "table") and val or {val}
+ val = (type(val) == "table") and val or {val}
local result