Software /
code /
prosody
Comparison
teal-src/util/xtemplate.tl @ 13500:997d9ad12477 0.12
util.xtemplate: Fix error on applying each() to zero stanzas
Backport of 1f93e4f78c53
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 11 Jul 2024 15:24:19 +0200 |
parent | 12213:dc9d63166488 |
comparison
equal
deleted
inserted
replaced
13497:da9be0ad4bbc | 13500:997d9ad12477 |
---|---|
44 if not func then func, p = s_match(inner, "^(%w+)()", pos as integer); end | 44 if not func then func, p = s_match(inner, "^(%w+)()", pos as integer); end |
45 if not func then break end | 45 if not func then break end |
46 if tmpl then tmpl = s_sub(tmpl, 2, -2); end | 46 if tmpl then tmpl = s_sub(tmpl, 2, -2); end |
47 if args then args = s_sub(args, 2, -2); end | 47 if args then args = s_sub(args, 2, -2); end |
48 | 48 |
49 if func == "each" and tmpl and st.is_stanza(value) then | 49 if func == "each" and tmpl then |
50 if not st.is_stanza(value) then | |
51 return ""; | |
52 end | |
50 if not args then value, args = root, path; end | 53 if not args then value, args = root, path; end |
51 local ns, name = s_match(args, "^(%b{})(.*)$"); | 54 local ns, name = s_match(args, "^(%b{})(.*)$"); |
52 if ns then ns = s_sub(ns, 2, -2); else name, ns = args, nil; end | 55 if ns then ns = s_sub(ns, 2, -2); else name, ns = args, nil; end |
53 if ns == "" then ns = nil; end | 56 if ns == "" then ns = nil; end |
54 if name == "" then name = nil; end | 57 if name == "" then name = nil; end |