From 6bb0a34965cfb0f57f3e2a19ba8f4584f1e799ed Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 13 Nov 2008 03:47:44 +0000 Subject: Add new top_tag() method to stanzas --- util/stanza.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/util/stanza.lua b/util/stanza.lua index 52f372cc..5339b91e 100644 --- a/util/stanza.lua +++ b/util/stanza.lua @@ -105,6 +105,14 @@ function stanza_mt.__tostring(t) return s_format("<%s%s>%s", t.name, attr_string, children_text, t.name); end +function stanza_mt.top_tag(t) + local attr_string = ""; + if t.attr then + for k, v in pairs(t.attr) do if type(k) == "string" then attr_string = attr_string .. s_format(" %s='%s'", k, tostring(v)); end end + end + return s_format("<%s%s>", t.name, attr_string); +end + function stanza_mt.__add(s1, s2) return s1:add_direct_child(s2); end -- cgit v1.2.3