mirror of
https://github.com/getgrav/grav.git
synced 2026-07-21 09:21:31 +02:00
added twig filters for starts_with and ends_with
This commit is contained in:
@@ -52,7 +52,9 @@ class TwigExtension extends \Twig_Extension
|
||||
new \Twig_SimpleFilter('contains', [$this, 'containsFilter']),
|
||||
new \Twig_SimpleFilter('nicetime', [$this, 'nicetimeFilter']),
|
||||
new \Twig_SimpleFilter('absolute_url', [$this, 'absoluteUrlFilter']),
|
||||
new \Twig_SimpleFilter('markdown', [$this, 'markdownFilter'])
|
||||
new \Twig_SimpleFilter('markdown', [$this, 'markdownFilter']),
|
||||
new \Twig_SimpleFilter('starts_with', [$this, 'startsWithFilter']),
|
||||
new \Twig_SimpleFilter('ends_with', [$this, 'endsWithFilter'])
|
||||
];
|
||||
}
|
||||
|
||||
@@ -347,6 +349,16 @@ class TwigExtension extends \Twig_Extension
|
||||
return $string;
|
||||
}
|
||||
|
||||
public function startsWithFilter($needle, $haystack)
|
||||
{
|
||||
return Utils::startsWith($needle, $haystack);
|
||||
}
|
||||
|
||||
public function endsWithFilter($needle, $haystack)
|
||||
{
|
||||
return Utils::endsWith($needle, $haystack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Repeat given string x times.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user