libs/cbi: attach pcdata() to template scope and use it
This commit is contained in:
parent
6b1be858be
commit
892ed55ba0
7 changed files with 9 additions and 8 deletions
|
@ -1340,6 +1340,7 @@ function AbstractValue.render(self, s, scope)
|
|||
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
|
||||
|
|
|
@ -15,8 +15,8 @@ $Id$
|
|||
|
||||
<%+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%>
|
||||
 
|
||||
<input type="hidden" id="<%=cbid%>" value="<%=luci.util.pcdata(self:cfgvalue(section))%>" />
|
||||
<input type="hidden" id="<%=cbid%>" value="<%=pcdata(self:cfgvalue(section))%>" />
|
||||
<%+cbi/valuefooter%>
|
||||
|
|
|
@ -18,7 +18,7 @@ $Id$
|
|||
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 %>
|
||||
|
|
|
@ -24,7 +24,7 @@ $Id$
|
|||
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()
|
||||
|
|
|
@ -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 -%>
|
||||
<li><%=luci.util.pcdata(e):gsub("\n","<br />")%></li>
|
||||
<li><%=pcdata(e):gsub("\n","<br />")%></li>
|
||||
<%- end end %></ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -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") %>>
|
||||
<%-=luci.util.pcdata(self:cfgvalue(section))-%>
|
||||
<%-=pcdata(self:cfgvalue(section))-%>
|
||||
</textarea>
|
||||
<%+cbi/valuefooter%>
|
||||
|
|
|
@ -17,7 +17,7 @@ $Id$
|
|||
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
|
||||
|
@ -27,7 +27,7 @@ $Id$
|
|||
|
||||
<% 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 %>
|
||||
|
||||
|
|
Loading…
Reference in a new issue