Software /
code /
prosody
Changeset
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 |
parents | 13497:da9be0ad4bbc |
children | 13501:05f028de4c45 13505:a97c11584042 |
files | teal-src/util/xtemplate.tl util/xtemplate.lua |
diffstat | 2 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/teal-src/util/xtemplate.tl Sun Jul 07 18:28:17 2024 +0200 +++ b/teal-src/util/xtemplate.tl Thu Jul 11 15:24:19 2024 +0200 @@ -46,7 +46,10 @@ 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 ""; + 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
--- a/util/xtemplate.lua Sun Jul 07 18:28:17 2024 +0200 +++ b/util/xtemplate.lua Thu Jul 11 15:24:19 2024 +0200 @@ -31,7 +31,8 @@ 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 "" end if not args then value, args = root, path; end local ns, name = s_match(args, "^(%b{})(.*)$"); if ns then