summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/templates/snom-template.lua38
1 files changed, 19 insertions, 19 deletions
diff --git a/config/templates/snom-template.lua b/config/templates/snom-template.lua
index e109c04..cdf830c 100644
--- a/config/templates/snom-template.lua
+++ b/config/templates/snom-template.lua
@@ -1,25 +1,25 @@
<%
local values = ...
-local function xml_elem(t,v,p,i)
- local elem = t
- if i == nil then
- if v == true then
- io.write('<'..elem..' perm="'..p..'">on</'..elem..'>\n')
- elseif v == false then
- io.write('<'..elem..' perm="'..p..'">off</'..elem..'>\n')
- else
- io.write('<'..elem..' perm="'..p..'">'..tostring(v)..'</'..elem..'>\n')
- end
- else
- if v == true then
- io.write('<'..elem..' idx="'..i..'" perm="'..p..'">on</'..elem..'>\n')
- elseif v == false then
- io.write('<'..elem..' idx="'..i..'" perm="'..p..'">off</'..elem..'>\n')
- else
- io.write('<'..elem..' idx="'..i..'" perm="'..p..'">'..tostring(v)..'</'..elem..'>\n')
- end
- end
+local function onoff ( bool )
+ if bool then
+ return "on"
+ else
+ return "off"
+ end
+end
+
+local function xml_elem(elem,value,permissions,i)
+ local output = {"<", elem, ' perm="', permissions, '"'}
+ if i then output[#output+1] = ' idx="'..i..'"' end
+ output[#output+1] = ">"
+ if type(value) == "boolean" then
+ output[#output+1] = onoff(value)
+ elseif value then
+ output[#output+1] = value
+ end
+ output[#output+1] = "</"..elem..">"
+ io.write(table.concat(output))
end
%>