Comparison

util/datamapper.lua @ 11438:b7807583de34

util.datamapper: Add logic for "boolean" tags here the presence means true
author Kim Alvefur <zash@zash.se>
date Sun, 07 Mar 2021 01:41:39 +0100
parent 11437:87a684df4b65
child 11439:9abcdfdcdb01
comparison
equal deleted inserted replaced
11437:87a684df4b65 11438:b7807583de34
46 end 46 end
47 end 47 end
48 48
49 if name_is_value then 49 if name_is_value then
50 local c = s:get_child(nil, namespace); 50 local c = s:get_child(nil, namespace);
51 if c then 51 if c and proptype == "string" then
52 out[prop] = c.name; 52 out[prop] = c.name;
53 elseif proptype == "boolean" and c then
54 out[prop] = true;
53 end 55 end
54 elseif is_attribute then 56 elseif is_attribute then
55 local attr = name 57 local attr = name
56 if prefix then 58 if prefix then
57 attr = prefix .. ":" .. name 59 attr = prefix .. ":" .. name
180 else 182 else
181 local propattr 183 local propattr
182 if namespace ~= current_ns then 184 if namespace ~= current_ns then
183 propattr = {xmlns = namespace} 185 propattr = {xmlns = namespace}
184 end 186 end
185 if name_is_value and type(v) == "string" then 187 if name_is_value then
186 out:tag(v, propattr):up(); 188 if proptype == "string" and type(v) == "string" then
189 out:tag(v, propattr):up();
190 elseif proptype == "boolean" and v == true then
191 out:tag(name, propattr):up();
192 end
187 elseif proptype == "string" and type(v) == "string" then 193 elseif proptype == "string" and type(v) == "string" then
188 out:text_tag(name, v, propattr) 194 out:text_tag(name, v, propattr)
189 elseif proptype == "number" and type(v) == "number" then 195 elseif proptype == "number" and type(v) == "number" then
190 out:text_tag(name, string.format("%g", v), propattr) 196 out:text_tag(name, string.format("%g", v), propattr)
191 elseif proptype == "integer" and type(v) == "number" then 197 elseif proptype == "integer" and type(v) == "number" then