From: Jo-Philipp Wich Date: Thu, 22 Sep 2011 16:33:28 +0000 (+0000) Subject: libs/web: cbi: provide a "last_child" property to allow for more layout control in... X-Git-Tag: 0.11.0~1733 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=96dd29753cc2ada1d704fdcbd38385a4e685c463;p=project%2Fluci.git libs/web: cbi: provide a "last_child" property to allow for more layout control in form rendering --- diff --git a/libs/web/luasrc/cbi.lua b/libs/web/luasrc/cbi.lua index 5dd57e2e96..5aa2f5a092 100644 --- a/libs/web/luasrc/cbi.lua +++ b/libs/web/luasrc/cbi.lua @@ -211,7 +211,9 @@ end -- Render the children function Node.render_children(self, ...) + local k, node for k, node in ipairs(self.children) do + node.last_child = (k == #self.children) node:render(...) end end @@ -805,7 +807,9 @@ function AbstractSection.render_tab(self, tab, ...) assert(tab and self.tabs and self.tabs[tab], "Cannot render not existing tab %q" % tostring(tab)) - for _, node in ipairs(self.tabs[tab].childs) do + local k, node + for k, node in ipairs(self.tabs[tab].childs) do + node.last_child = (k == #self.tabs[tab].childs) node:render(...) end end