rcrowe / TwigBridge

Give the power of Twig to Laravel
MIT License
894 stars 167 forks source link

Allow .js.twig, .css.twig and .txt.twig extensions #246

Open mnpenner opened 8 years ago

mnpenner commented 8 years ago

I don't always use HTML and my underlying template language with Twig. PhpStorm supports .js.twig and other extensions.

I tried changing the config option,

'extension' => 'twig',

to

'extension' => ['twig','js.twig','css.twig'],

but it doesn't seem to support array notation.

This used to work with Barry's version in Laravel 4.2, but I see that the loader now goes through Laravel's own engine, which I guess doesn't load anything unless it's been registered.

barryvdh commented 8 years ago

Not sure if the engine is able to register multiple extensions, otherwise I'm okay with this.

eightyfive commented 8 years ago

Would like that as well in order to allow inlining JS & CSS resources ({% include '...' %})

sgueyemms commented 8 years ago

I am interested in this feature. Being able to use template with names like *.html.twig will make it easy to reuse a lot of templates (from Symfony 2 bundles or libraries that use the same convention).

I had a look at the implementation. By delegating template name normalization it can support mutiple extensions. It will require some changes in the Loader, Bridge and ServiceProvider. See sgueye-multi-twig-extensions

svenluijten commented 6 years ago

Hi @sgueyemms. Did you end up submitting a pull request for this?

Otherwise I'd gladly "take over" your fork and submit a PR for this 🙂