Diff

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
line wrap: on
line diff
--- a/teal-src/util/datamapper.tl	Sat Mar 06 23:14:23 2021 +0100
+++ b/teal-src/util/datamapper.tl	Sun Mar 07 01:41:39 2021 +0100
@@ -49,8 +49,10 @@
 
 			if name_is_value then
 				local c = s:get_child(nil, namespace);
-				if c then
+				if c and proptype == "string" then
 					out[prop] = c.name;
+				elseif proptype == "boolean" and c then
+					out[prop] = true;
 				end
 			elseif is_attribute then
 				local attr = name
@@ -183,8 +185,12 @@
 					if namespace ~= current_ns then
 						propattr = { xmlns = namespace }
 					end
-					if name_is_value and v is string then
-						out:tag(v, propattr):up();
+					if name_is_value then
+						if proptype == "string" and v is string then
+							out:tag(v, propattr):up();
+						elseif proptype == "boolean" and v == true then
+							out:tag(name, propattr):up();
+						end
 					elseif proptype == "string" and v is string then
 						out:text_tag(name, v, propattr)
 					elseif proptype == "number" and v is number then