diff options
author | Ted Trask <ttrask01@yahoo.com> | 2011-11-03 19:43:08 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2011-11-03 19:43:08 +0000 |
commit | 6d8776a8a70126a142664d28b3ef766880503043 (patch) | |
tree | 5350eee9ac5c2c689e9a6ef6d6876a38863dc51d /config | |
parent | 2ff826fd58234975d4c13b28526283deb7d688a6 (diff) | |
download | acf-provisioning-6d8776a8a70126a142664d28b3ef766880503043.tar.bz2 acf-provisioning-6d8776a8a70126a142664d28b3ef766880503043.tar.xz |
Rewrite of snom xml_elem function
Diffstat (limited to 'config')
-rw-r--r-- | config/templates/snom-template.lua | 38 |
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 %> |