Skip to content

liquid.filters.wild

module

liquid.filters.wild

Provides some wild filters

Functions
  • call(fn, *args, **kwargs) (any) Call a function with passed arguments</>
  • ifelse(env, value, test, test_args, true, true_args, false, false_args) (any) An if-else filter, implementing a tenary-like filter.</>
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 value
  • test (any) The test callable or filter name
  • test_args (any, optional) Other args (value as the first arg) for the test
  • true (any, optional) The callable or filter name when test is True
  • true_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 self
  • false (any, optional) The callable or filter name when test is False
  • false_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