Karmabunny / sprout3

SproutCMS: content management and framework
http://getsproutcms.com
GNU General Public License v2.0
24 stars 3 forks source link

Feat/inline twig #112

Closed gwillz closed 3 months ago

gwillz commented 5 months ago

Twig string templates. Handy things.

These are something you can hand to (admin) users to do little snippets of logic from a content managed environment.

Use it something like:

$items = [
   ['name' => 'abc'],
   ['bad'],
   ['name' => 'def'],
];
$template = '{{ items|map(item => item.name ?? false)|filter|join(', ') }}';
$html = TwigView::renderString($template, [ 'items' => $items ]);