mirror of
https://github.com/bjc/prosody.git
synced 2025-03-31 11:47:40 +03:00
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.
This commit is contained in:
parent
eb612ac519
commit
2ef0e122fd
2 changed files with 3 additions and 11 deletions
|
@ -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
|
||||
|
@ -85,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
|
||||
|
|
|
@ -70,11 +70,7 @@ local function render(template, root, escape, filters)
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue