TwigBridge icon indicating copy to clipboard operation
TwigBridge copied to clipboard

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

Open mnpenner opened this issue 10 years ago • 4 comments

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.

mnpenner avatar Dec 31 '15 01:12 mnpenner

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

barryvdh avatar Jan 01 '16 16:01 barryvdh

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

eightyfive avatar Feb 04 '16 05:02 eightyfive

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

sgueyemms avatar Aug 30 '16 18:08 sgueyemms

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 🙂

svenluijten avatar Mar 15 '18 15:03 svenluijten