Diff

util/stanza.lua @ 1420:1576a5aa52f8

util.stanza: Add stanza:get_text() to retrieve all child text nodes #api
author Matthew Wild <mwild1@gmail.com>
date Fri, 26 Jun 2009 05:54:55 +0100
parent 1416:f916f0ff90e5
child 1431:9fe9ba693f4a
line wrap: on
line diff
--- a/util/stanza.lua	Fri Jun 26 05:54:03 2009 +0100
+++ b/util/stanza.lua	Fri Jun 26 05:54:55 2009 +0100
@@ -158,6 +158,12 @@
 	return s_format("<%s%s>", t.name, attr_string);
 end
 
+function stanza_mt.get_text(t)
+	if #t.tags == 0 then
+		return t_concat(t);
+	end
+end
+
 function stanza_mt.__add(s1, s2)
 	return s1:add_direct_child(s2);
 end