Skip to content

Commit

Permalink
Merge pull request #48 from samwilson/dirname
Browse files Browse the repository at this point in the history
Add dirname Twig filter
  • Loading branch information
samwilson authored Apr 25, 2022
2 parents 714af33 + c50bff4 commit faeda12
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
"bin/basildon"
],
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": false,
"ergebnis/composer-normalize": true
},
"platform": {
"php": "7.3"
}
Expand Down
2 changes: 2 additions & 0 deletions docs/content/templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ these are explained on this page.
2. `md2latex` – Filter markdown to LaTeX.
3. `escape('tex')` – Escaper to use in TeX templates to escape characters that have special meaning in TeX, e.g. `{{ '$10'|e('tex') }}`.
This is often used by wrapping the template in `{% autoescape 'tex' %}{% endautoescape %}`
4. `dirname` and `basename` — Identical to PHP's [dirname()](https://www.php.net/manual/en/function.dirname.php)
and [basename()](https://www.php.net/manual/en/function.basename.php) functions. Useful for working with Basildon page IDs.
1 change: 1 addition & 0 deletions src/Twig.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function getFilters(): array
{
return [
new TwigFilter('basename', 'basename'),
new TwigFilter('dirname', 'dirname'),
new TwigFilter('md2html', [$this, 'filterMarkdownToHtml']),
new TwigFilter('md2latex', [$this, 'filterMarkdownToLatex']),
];
Expand Down

0 comments on commit faeda12

Please sign in to comment.