mirror of
https://github.com/OPSnet/Gazelle.git
synced 2026-10-19 01:03:12 -04:00
Some useful Twig filters (and number_format is already built in).
This commit is contained in:
@@ -74,9 +74,9 @@ G::$Twig = new Environment(
|
||||
);
|
||||
|
||||
G::$Twig->addFilter(new \Twig\TwigFilter(
|
||||
'number_format',
|
||||
function ($text) {
|
||||
return number_format($text);
|
||||
'article',
|
||||
function ($word) {
|
||||
return preg_match('/^[aeiou]/i', $word) ? 'an' : 'a';
|
||||
}
|
||||
));
|
||||
|
||||
@@ -94,6 +94,13 @@ G::$Twig->addFilter(new \Twig\TwigFilter(
|
||||
}
|
||||
));
|
||||
|
||||
G::$Twig->addFilter(new \Twig\TwigFilter(
|
||||
'plural',
|
||||
function ($number) {
|
||||
return plural($number);
|
||||
}
|
||||
));
|
||||
|
||||
G::$Twig->addFilter(new \Twig\TwigFilter(
|
||||
'selected',
|
||||
function ($isSelected) {
|
||||
@@ -101,6 +108,20 @@ G::$Twig->addFilter(new \Twig\TwigFilter(
|
||||
}
|
||||
));
|
||||
|
||||
G::$Twig->addFilter(new \Twig\TwigFilter(
|
||||
'time_diff',
|
||||
function ($time) {
|
||||
return time_diff($time);
|
||||
}
|
||||
));
|
||||
|
||||
G::$Twig->addFilter(new \Twig\TwigFilter(
|
||||
'user_url',
|
||||
function ($userId) {
|
||||
return Users::format_username($userId, false, false, false);
|
||||
}
|
||||
));
|
||||
|
||||
G::$Twig->addFilter(new \Twig\TwigFilter(
|
||||
'ucfirstall',
|
||||
function ($text) {
|
||||
|
||||
Reference in New Issue
Block a user