Software /
code /
prosody
Changeset
242:f15afbcbc55c
Add new top_tag() method to stanzas
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 13 Nov 2008 03:47:44 +0000 |
parents | 241:021ccf988f3b |
children | 243:09a80c8b2d73 |
files | util/stanza.lua |
diffstat | 1 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/util/stanza.lua Wed Nov 12 19:26:08 2008 +0000 +++ b/util/stanza.lua Thu Nov 13 03:47:44 2008 +0000 @@ -105,6 +105,14 @@ 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