Skip to content

Commit c138fca

Browse files
authored
Merge pull request #152 from getherbie/2.x-develop
2.x develop
2 parents cdf2a8f + 7977234 commit c138fca

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

.github/workflows/cicd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
strategy:
88
matrix:
99
# operating-systems: ubuntu-latest, windows-latest, macos-latest
10-
operating-system: [ubuntu-latest]
10+
operating-system: [ubuntu-latest, macos-latest]
1111
php-versions: ['8.0', '8.1', '8.2', '8.3']
1212
runs-on: ${{ matrix.operating-system }}
1313
steps:

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file.
33

44
## [Unreleased]
55

6+
## [2.2.0] - 2025-05-23
7+
8+
### Added
9+
- New `twigify` Twig filter to render a string with Twig
10+
- New `twigify` Twig function to render a string with Twig
11+
612
## [2.1.0] - 2025-04-13
713

814
### Added
@@ -44,7 +50,8 @@ See https://github.com/getherbie/herbie/issues/82.
4450
The format is based on [Keep a Changelog](http://keepachangelog.com/)
4551
and this project adheres to [Semantic Versioning](http://semver.org/).
4652

47-
[Unreleased]: https://github.com/getherbie/herbie/compare/v2.1.0...HEAD
53+
[Unreleased]: https://github.com/getherbie/herbie/compare/v2.2.0...HEAD
54+
[2.2.0]: https://github.com/getherbie/herbie/compare/v2.1.0...v2.2.0
4855
[2.1.0]: https://github.com/getherbie/herbie/compare/v2.0.0...v2.1.0
4956
[2.0.0]: https://github.com/getherbie/herbie/compare/v1.1.0...v2.0.0
5057
[1.1.0]: https://github.com/getherbie/herbie/compare/v1.0.1...v1.1.0

plugins/twig/TwigExtension.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public function getFilters(): array
7474
return [
7575
new TwigFilter('format_size', [$this, 'filterFilesize']),
7676
new TwigFilter('slugify', [$this, 'filterSlugify']),
77+
new TwigFilter('twigify', [$this, 'twigify'], ['is_safe' => ['html']]),
7778
new TwigFilter('visible', [$this, 'filterVisible'], ['deprecated' => true]) // doesn't work properly
7879
];
7980
}
@@ -104,6 +105,7 @@ public function getFunctions(): array
104105
new TwigFunction('query', [$this, 'query']),
105106
new TwigFunction('snippet', [$this, 'snippet'], ['is_safe' => ['all']]),
106107
new TwigFunction('translate', [$this, 'translate']),
108+
new TwigFunction('twigify', [$this, 'twigify'], ['is_safe' => ['html']]),
107109
new TwigFunction('url_rel', [$this, 'urlRelative']),
108110
new TwigFunction('url_abs', [$this, 'urlAbsolute']),
109111
];
@@ -659,4 +661,9 @@ public function testIsWritable(string $alias): bool
659661
$filename = $this->alias->get($alias);
660662
return is_writable($filename);
661663
}
664+
665+
public function twigify(string $content): string
666+
{
667+
return $this->environment->render($content);
668+
}
662669
}

tests/acceptance/HerbieInfoCest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ public function testNumberAndSortingOfTwigFilters(AcceptanceTester $I)
380380
'raw',
381381
'format_size',
382382
'slugify',
383+
'twigify',
383384
'visible',
384385
'markdown',
385386
'rest',
@@ -430,6 +431,7 @@ public function testNumberAndSortingOfTwigFunctions(AcceptanceTester $I)
430431
'query',
431432
'snippet',
432433
'translate',
434+
'twigify',
433435
'url_rel',
434436
'url_abs',
435437
'herbie_debug',

0 commit comments

Comments
 (0)