frctl / twig

Use Twig templates with Fractal.
32 stars 34 forks source link

Include with arrays #15

Closed adrienne closed 5 years ago

adrienne commented 6 years ago

So I don't know if this even works in Twig.js itself, but honestly Fractal could implement it for the Twig handler regardless? You should be able to pass an array to {% include %}, and Twig should stop at the first template it finds. So for instance:

{% include ['@site-mobile-nav', 'site-mobile-nav/site-mobile-nav.twig'] %}

Should render the @site-mobile-nav component inside Fractal (and site-mobile-nav/site-mobile-nav.twig anywhere else I copy the Twig template to.) Currently it throws an error.

Chapabu commented 5 years ago

This is a feature of the original PHP Twig implementation (https://twig.symfony.com/doc/2.x/tags/include.html) so it's not outside the realms of possibility. However we wouldn't want to add features to Twig.js here, that's the responsibility of the underlying Twig.js library.

I'm going to close this one as it's not our responsibility. However, there is an issue on the main Twig.js repo here twigjs/twig.js#468 that it would be worth following.

justafish commented 4 years ago

https://github.com/twigjs/twig.js/pull/681