@@ -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}
0 commit comments