# HG changeset patch # User Kim Alvefur # Date 1521670826 -3600 # Node ID 06c73b0104883118a225fad99762fbc222275a6b # Parent 3b28c7728e3f0613d184c710a81d53670a5c8a53 util.stanza: Add :text_tag(), a shortcut for adding nodes with text diff -r 3b28c7728e3f -r 06c73b010488 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;