aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2008-11-13 03:47:44 +0000
committerMatthew Wild <mwild1@gmail.com>2008-11-13 03:47:44 +0000
commit6bb0a34965cfb0f57f3e2a19ba8f4584f1e799ed (patch)
tree0d4eef023e9dfeae657ce9109e966d05696012c1 /util
parent564fb0420a1e83294462f83cfe735fac3aae7875 (diff)
downloadprosody-6bb0a34965cfb0f57f3e2a19ba8f4584f1e799ed.tar.gz
prosody-6bb0a34965cfb0f57f3e2a19ba8f4584f1e799ed.zip
Add new top_tag() method to stanzas
Diffstat (limited to 'util')
-rw-r--r--util/stanza.lua8
1 files changed, 8 insertions, 0 deletions
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</%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