liquid.filters.wild
module
liquid.filters.wild
function
liquid.filters.wild.
ifelse
(
env
, value
, test
, test_args=()
, true=None
, true_args=()
, false=None
, false_args=()
)
An if-else filter, implementing a tenary-like filter.
Use ifelse
or if_else
.
Examples
>>> {{ a | ifelse: isinstance, (int, ),>>> "plus", (1, ),
>>> "append", (".html", ) }}
>>> # 2 when a = 1
>>> # "a.html" when a = "a"
Parameters
value
(any) — The base valuetest
(any) — The test callable or filter nametest_args
(any, optional) — Other args (value as the first arg) for the testtrue
(any, optional) — The callable or filter name when test is Truetrue_args
(any, optional) — Other args (value as the first arg) for the trueWhen this is None, return the true callable itself or the name of the filter it selffalse
(any, optional) — The callable or filter name when test is Falsefalse_args
(any, optional) — Other args (value as the first arg) for the falseWhen this is None, return the false callable itself or the name of the filter it self
Returns (any)
The result of true of test result is True otherwise result of false.
function
liquid.filters.wild.
call
(
fn
, *args
, **kwargs
)
Call a function with passed arguments
Examples
>>> {{ int | call: "1" | plus: 1 }}>>> # 2
Parameters
fn
— The callable*args
— and**kwargs
— The arguments for the callable
Returns (any)
The result of calling the function