Software /
code /
prosody
Changeset
13525:0f7e7311eebf
util.xtemplate: Use same argument order in filters even without 'args'
This removes the different argument order used between '{x|foo}' and
'{x|foo(y)}' because the differing order was awkward and confusing.
This util does not seem to be widely used so should not be problematic
to change this part. The only known use is in mod_pubsub, which does not
use the filter function feature.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 16 Oct 2024 16:15:05 +0200 |
parents | 13524:cfc42ed3892c |
children | 13526:3abed2ec7ab6 |
files | teal-src/prosody/util/xtemplate.tl util/xtemplate.lua |
diffstat | 2 files changed, 3 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/teal-src/prosody/util/xtemplate.tl Sun Oct 13 13:03:08 2024 +0200 +++ b/teal-src/prosody/util/xtemplate.tl Wed Oct 16 16:15:05 2024 +0200 @@ -17,7 +17,7 @@ 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 @@ -85,11 +85,7 @@ 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
--- a/util/xtemplate.lua Sun Oct 13 13:03:08 2024 +0200 +++ b/util/xtemplate.lua Wed Oct 16 16:15:05 2024 +0200 @@ -70,11 +70,7 @@ 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