Comparison

util/stanza.lua @ 23:236375777f8c

Some docs written by Thorns. Need reviewing.
author bt@silverblade
date Wed, 17 Sep 2008 22:20:08 +0300
parent 6:7ad47ce20394
child 30:bcf539295f2d
comparison
equal deleted inserted replaced
21:ade26639f237 23:236375777f8c
1 local t_insert = table.insert; 1 local t_insert = table.insert;
2 local t_remove = table.remove; 2 local t_remove = table.remove;
3 local format = string.format; 3 local s_format = string.format;
4 local tostring = tostring; 4 local tostring = tostring;
5 local setmetatable = setmetatable; 5 local setmetatable = setmetatable;
6 local pairs = pairs; 6 local pairs = pairs;
7 local ipairs = ipairs; 7 local ipairs = ipairs;
8 local type = type; 8 local type = type;
95 end 95 end
96 end 96 end
97 97
98 local attr_string = ""; 98 local attr_string = "";
99 if t.attr then 99 if t.attr then
100 for k, v in pairs(t.attr) do if type(k) == "string" then attr_string = attr_string .. format(" %s='%s'", k, tostring(v)); end end 100 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
101 end 101 end
102 102
103 return format("<%s%s>%s</%s>", t.name, attr_string, children_text, t.name); 103 return s_format("<%s%s>%s</%s>", t.name, attr_string, children_text, t.name);
104 end 104 end
105 105
106 function stanza_mt.__add(s1, s2) 106 function stanza_mt.__add(s1, s2)
107 return s1:add_child(s2); 107 return s1:add_child(s2);
108 end 108 end