Software /
code /
prosody
Comparison
teal-src/util/datamapper.tl @ 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 |
---|---|
47 end | 47 end |
48 end | 48 end |
49 | 49 |
50 if name_is_value then | 50 if name_is_value then |
51 local c = s:get_child(nil, namespace); | 51 local c = s:get_child(nil, namespace); |
52 if c then | 52 if c and proptype == "string" then |
53 out[prop] = c.name; | 53 out[prop] = c.name; |
54 elseif proptype == "boolean" and c then | |
55 out[prop] = true; | |
54 end | 56 end |
55 elseif is_attribute then | 57 elseif is_attribute then |
56 local attr = name | 58 local attr = name |
57 if prefix then | 59 if prefix then |
58 attr = prefix .. ':' .. name | 60 attr = prefix .. ':' .. name |
181 else | 183 else |
182 local propattr : { string : string } | 184 local propattr : { string : string } |
183 if namespace ~= current_ns then | 185 if namespace ~= current_ns then |
184 propattr = { xmlns = namespace } | 186 propattr = { xmlns = namespace } |
185 end | 187 end |
186 if name_is_value and v is string then | 188 if name_is_value then |
187 out:tag(v, propattr):up(); | 189 if proptype == "string" and v is string then |
190 out:tag(v, propattr):up(); | |
191 elseif proptype == "boolean" and v == true then | |
192 out:tag(name, propattr):up(); | |
193 end | |
188 elseif proptype == "string" and v is string then | 194 elseif proptype == "string" and v is string then |
189 out:text_tag(name, v, propattr) | 195 out:text_tag(name, v, propattr) |
190 elseif proptype == "number" and v is number then | 196 elseif proptype == "number" and v is number then |
191 out:text_tag(name, string.format("%g", v), propattr) | 197 out:text_tag(name, string.format("%g", v), propattr) |
192 elseif proptype == "integer" and v is number then | 198 elseif proptype == "integer" and v is number then |