libs/cbi: attach pcdata() to template scope and use it
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 13 Aug 2009 17:14:25 +0000 (17:14 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 13 Aug 2009 17:14:25 +0000 (17:14 +0000)
libs/cbi/luasrc/cbi.lua
libs/cbi/luasrc/view/cbi/dvalue.htm
libs/cbi/luasrc/view/cbi/dynlist.htm
libs/cbi/luasrc/view/cbi/map.htm
libs/cbi/luasrc/view/cbi/tblsection.htm
libs/cbi/luasrc/view/cbi/tvalue.htm
libs/cbi/luasrc/view/cbi/ucisection.htm

index 83f5c27..044993a 100644 (file)
@@ -1340,6 +1340,7 @@ function AbstractValue.render(self, s, scope)
                scope.section   = s
                scope.cbid      = self:cbid(s)
                scope.striptags = luci.util.striptags
                scope.section   = s
                scope.cbid      = self:cbid(s)
                scope.striptags = luci.util.striptags
+               scope.pcdata    = luci.util.pcdata
 
                scope.ifattr = function(cond,key,val)
                        if cond then
 
                scope.ifattr = function(cond,key,val)
                        if cond then
index 28cd9ab..819860a 100644 (file)
@@ -15,8 +15,8 @@ $Id$
 
 <%+cbi/valueheader%>
 <% if self.href then %><a href="<%=self.href%>"><% end -%>
 
 <%+cbi/valueheader%>
 <% if self.href then %><a href="<%=self.href%>"><% end -%>
-       <%=luci.util.pcdata(self:cfgvalue(section))%>
+       <%=pcdata(self:cfgvalue(section))%>
 <%- if self.href then %></a><%end%>
 &#160;
 <%- if self.href then %></a><%end%>
 &#160;
-<input type="hidden" id="<%=cbid%>" value="<%=luci.util.pcdata(self:cfgvalue(section))%>" />
+<input type="hidden" id="<%=cbid%>" value="<%=pcdata(self:cfgvalue(section))%>" />
 <%+cbi/valuefooter%>
 <%+cbi/valuefooter%>
index 1f3b901..cbde2ef 100644 (file)
@@ -18,7 +18,7 @@ $Id$
        for i=1, #vals + 1 do
                local val = vals[i]
 %>
        for i=1, #vals + 1 do
                local val = vals[i]
 %>
-       <input class="cbi-input-text" value="<%=luci.util.pcdata(val)%>" onchange="cbi_d_update(this.id)" type="text"<%= attr("id", cbid .. "." .. i) .. attr("name", cbid) .. ifattr(self.size, "size")%> />
+       <input class="cbi-input-text" value="<%=pcdata(val)%>" onchange="cbi_d_update(this.id)" type="text"<%= attr("id", cbid .. "." .. i) .. attr("name", cbid) .. ifattr(self.size, "size")%> />
        <% if i <= #vals then %>
                <input class="cbi-input-image" type="image" value="<%:cbi_del%>" name="cbi.rle.<%=section .. "." .. self.option .. "." .. i%>" alt="<%:cbi_del%>" title="<%:cbi_del%>" src="<%=resource%>/cbi/remove.gif" />
        <% else %>
        <% if i <= #vals then %>
                <input class="cbi-input-image" type="image" value="<%:cbi_del%>" name="cbi.rle.<%=section .. "." .. self.option .. "." .. i%>" alt="<%:cbi_del%>" title="<%:cbi_del%>" src="<%=resource%>/cbi/remove.gif" />
        <% else %>
index 949edea..0b5ac58 100644 (file)
@@ -24,7 +24,7 @@ $Id$
                                self._apply = nil
                                local line = fp:read()
                                while line do
                                self._apply = nil
                                local line = fp:read()
                                while line do
-                                       write("<li>" .. luci.util.pcdata(line) .. "</li>\n")
+                                       write("<li>" .. pcdata(line) .. "</li>\n")
                                        line = fp:read()
                                end
                                fp:close()
                                        line = fp:read()
                                end
                                fp:close()
index 029ad66..99b5b97 100644 (file)
@@ -109,7 +109,7 @@ end
                <% if self.error then %>
                        <div class="cbi-section-error">
                                <ul><% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
                <% if self.error then %>
                        <div class="cbi-section-error">
                                <ul><% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
-                                       <li><%=luci.util.pcdata(e):gsub("\n","<br />")%></li>
+                                       <li><%=pcdata(e):gsub("\n","<br />")%></li>
                                <%- end end %></ul>
                        </div>
                <% end %>
                                <%- end end %></ul>
                        </div>
                <% end %>
index 36782d8..b628c5c 100644 (file)
@@ -14,6 +14,6 @@ $Id$
 -%>
 <%+cbi/valueheader%>
        <textarea class="cbi-input-textarea" <% if not self.size then %> style="width: 100%"<% else %> cols="<%=self.size%>"<% end %> onchange="cbi_d_update(this.id)"<%= attr("name", cbid) .. attr("id", cbid) .. ifattr(self.rows, "rows") .. ifattr(self.wrap, "wrap") %>>
 -%>
 <%+cbi/valueheader%>
        <textarea class="cbi-input-textarea" <% if not self.size then %> style="width: 100%"<% else %> cols="<%=self.size%>"<% end %> onchange="cbi_d_update(this.id)"<%= attr("name", cbid) .. attr("id", cbid) .. ifattr(self.rows, "rows") .. ifattr(self.wrap, "wrap") %>>
-       <%-=luci.util.pcdata(self:cfgvalue(section))-%>
+       <%-=pcdata(self:cfgvalue(section))-%>
        </textarea>
 <%+cbi/valuefooter%>
        </textarea>
 <%+cbi/valuefooter%>
index 7e8467c..241681f 100644 (file)
@@ -17,7 +17,7 @@ $Id$
        if type(self.hidden) == "table" then
                for k, v in pairs(self.hidden) do
 -%>
        if type(self.hidden) == "table" then
                for k, v in pairs(self.hidden) do
 -%>
-       <input type="hidden" id="cbid.<%=self.config%>.<%=section%>.<%=k%>" name="cbid.<%=self.config%>.<%=section%>.<%=k%>" value="<%=luci.util.pcdata(v)%>" />
+       <input type="hidden" id="cbid.<%=self.config%>.<%=section%>.<%=k%>" name="cbid.<%=self.config%>.<%=section%>.<%=k%>" value="<%=pcdata(v)%>" />
 <%-
                end
        end
 <%-
                end
        end
@@ -27,7 +27,7 @@ $Id$
 
 <% if self.error and self.error[section] then -%>
        <div class="cbi-section-error">
 
 <% if self.error and self.error[section] then -%>
        <div class="cbi-section-error">
-               <ul><% for _, e in ipairs(self.error[section]) do %><li><%=luci.util.pcdata(e):gsub("\n","<br />")%></li><% end %></ul>
+               <ul><% for _, e in ipairs(self.error[section]) do %><li><%=pcdata(e):gsub("\n","<br />")%></li><% end %></ul>
        </div>
 <%- end %>
 
        </div>
 <%- end %>