aboutsummaryrefslogtreecommitdiffstats
path: root/teal-src
diff options
context:
space:
mode:
Diffstat (limited to 'teal-src')
-rw-r--r--teal-src/prosody/util/xtemplate.tl13
1 files changed, 6 insertions, 7 deletions
diff --git a/teal-src/prosody/util/xtemplate.tl b/teal-src/prosody/util/xtemplate.tl
index 9b6b678b..4d293359 100644
--- a/teal-src/prosody/util/xtemplate.tl
+++ b/teal-src/prosody/util/xtemplate.tl
@@ -17,7 +17,7 @@ local t_concat = table.concat;
local st = require "prosody.util.stanza";
local type escape_t = function (string) : string
-local type filter_t = function (string, string | st.stanza_t, string) : string | st.stanza_t, boolean
+local type filter_t = function (string | st.stanza_t, string | st.stanza_t, string) : string | st.stanza_t, boolean
local type filter_coll = { string : filter_t }
local function render(template : string, root : st.stanza_t, escape : escape_t, filters : filter_coll) : string
@@ -54,7 +54,10 @@ local function render(template : string, root : st.stanza_t, escape : escape_t,
if tmpl then tmpl = s_sub(tmpl, 2, -2); end
if args then args = s_sub(args, 2, -2); end
- if func == "each" and tmpl and st.is_stanza(value) then
+ if func == "each" and tmpl then
+ if not st.is_stanza(value) then
+ return pre_blank..post_blank;
+ end
if not args then value, args = root, path; end
local ns, name = s_match(args, "^(%b{})(.*)$");
if ns then ns = s_sub(ns, 2, -2); else name, ns = args, nil; end
@@ -82,11 +85,7 @@ local function render(template : string, root : st.stanza_t, escape : escape_t,
end
elseif filters and filters[func] then
local f = filters[func];
- if args == nil then
- value, is_escaped = f(value, tmpl);
- else
- value, is_escaped = f(args, value, tmpl);
- end
+ value, is_escaped = f(value, args, tmpl);
else
error("No such filter function: " .. func);
end