# HG changeset patch # User Kim Alvefur # Date 1729088105 -7200 # Node ID 0f7e7311eebf7eca7ed49de10e63d9cb73c99d21 # Parent cfc42ed3892c7b93e464e154d80e2d15ac87ac7c 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. diff -r cfc42ed3892c -r 0f7e7311eebf teal-src/prosody/util/xtemplate.tl --- 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 diff -r cfc42ed3892c -r 0f7e7311eebf util/xtemplate.lua --- 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