util.stanza: Add stanza:get_text() to retrieve all child text nodes #api

Fri, 26 Jun 2009 05:54:55 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Fri, 26 Jun 2009 05:54:55 +0100
changeset 1420
1576a5aa52f8
parent 1419
1ac8bcc63a9d
child 1421
7dafb3bae02b

util.stanza: Add stanza:get_text() to retrieve all child text nodes #api

util/stanza.lua file | annotate | diff | comparison | revisions
--- 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

mercurial