diff options
author | Steven Barth <steven@midlink.org> | 2008-08-15 18:18:16 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-08-15 18:18:16 +0000 |
commit | d212e531d5b2b5933676b3ec3004c2be60980f97 (patch) | |
tree | 22be5c2b8563f62701621a1ae62d376b3efb682b /libs/cbi/luasrc | |
parent | 5941f334ff118be916468101c7994a92e86cf0c2 (diff) |
Added missing value escaping
Fixed a typo (wrong if-condition)
Added support for Table objects in CBI
Diffstat (limited to 'libs/cbi/luasrc')
-rw-r--r-- | libs/cbi/luasrc/cbi.lua | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua index ecc910a13..7bcfceb2e 100644 --- a/libs/cbi/luasrc/cbi.lua +++ b/libs/cbi/luasrc/cbi.lua @@ -479,6 +479,30 @@ function SimpleSection.__init__(self, form, ...) end +Table = class(AbstractSection) + +function Table.__init__(self, form, data, ...) + local datasource = {} + self.data = data + + function datasource.get(self, section, option) + return data[option] + end + + AbstractSection.__init__(self, datasource, nil, ...) +end + +function Table.cfgsections(self) + local sections = {} + + for i, v in pairs(self.data) do + table.insert(sections, i) + end + + return sections +end + + --[[ NamedSection - A fixed configuration section defined by its name @@ -707,7 +731,7 @@ function AbstractValue.parse(self, section) else -- Unset the UCI or error if self.rmempty or self.optional then self:remove(section) - elseif self.track_missing and not fvalue or fvalue ~= cvalue then + elseif self.track_missing and (not fvalue or fvalue ~= cvalue) then self.tag_missing[section] = true end end @@ -726,10 +750,10 @@ function AbstractValue.render(self, s, scope) if cond then return string.format( ' %s="%s"', tostring(key), - tostring( val + luci.util.pcdata(tostring( val or scope[key] or (type(self[key]) ~= "function" and self[key]) - or "" ) + or "" )) ) else return '' |