Static class containing global filter map.
The built-in default filters are:
h
: HTML-escape input string (including quotes).u
: URL-escape input string.json
: JSON-encode input value.hash
: Hash input value. Requires hash algorithm as parameter.base64
: Base64-encode input string.nl2br
: Convert newlines to \<br/\>
elements.uc
: Upper-case input string.lc
: Lower-case input string.trim
: Trim leading and trailing whitespace from input string.ltrim
: Trim leading whitespace from input string.rtrim
: Trim trailing whitespace from input string.s
: Return '' if input number is 1, and 's' otherwise (used for
pluralization).strlen
: Return the length of the input string.count
: Return the number of elements in the input array.key
: Get the given key from the input array. Requires key as a
parameter.You can add your own filters to the default set of filters by
modifying \Luigi\Filters::$FILTERS
, like so:
# add a filter named "my-filter"
\Luigi\Filters['my-filter'] = function($s) {
# filter input string
return "foo-{$s}-bar";
};
# use custom filter in template
echo Template::once('%{some-key | my-filter}', [
'some-key' => 'example',
]) . "\n";
# prints "foo-example-bar"
api | |
---|---|
package |
Pablotron\Luigi |
FILTERS : array
var |
Global filter map. |
---|---|
api |
array