util.stanza: Add :text_tag(), a shortcut for adding nodes with text
authorKim Alvefur <zash@zash.se>
Wed, 21 Mar 2018 23:20:26 +0100
changeset 8648 06c73b010488
parent 8647 3b28c7728e3f
child 8649 a267dfa9d81d
util.stanza: Add :text_tag(), a shortcut for adding nodes with text
util/stanza.lua
--- a/util/stanza.lua	Wed Mar 21 23:15:30 2018 +0100
+++ b/util/stanza.lua	Wed Mar 21 23:20:26 2018 +0100
@@ -101,6 +101,10 @@
 	return self:tag("body", attr):text(text);
 end
 
+function stanza_mt:text_tag(name, text, attr, namespaces)
+	return self:tag(name, attr, namespaces):text(text):up();
+end
+
 function stanza_mt:tag(name, attr, namespaces)
 	local s = new_stanza(name, attr, namespaces);
 	local last_add = self.last_add;