projects
/
prosody.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
7b8041d
)
Add new top_tag() method to stanzas
author
Matthew Wild
<mwild1@gmail.com>
Thu, 13 Nov 2008 03:47:44 +0000
(
03:47
+0000)
committer
Matthew Wild
<mwild1@gmail.com>
Thu, 13 Nov 2008 03:47:44 +0000
(
03:47
+0000)
util/stanza.lua
patch
|
blob
|
history
diff --git
a/util/stanza.lua
b/util/stanza.lua
index 52f372cc8efd27f505c1116398115ba8678019ef..5339b91e4adb0557d889c21d99968ab089b44133 100644
(file)
--- 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