Inline all scripts in asset_scripts(..) instead of echo script tags
Created 6 years ago by finnitoHey all,
I want to use the asset_inline()
Twig command to inline all the scripts contained inside the asset_scripts()
collection but can't quite figure out the syntax.
In the docs they give the following syntax to loop through all the scripts in the collection:
{% for script in asset_scripts("scripts.js") %}
{{ script|raw }}
{% endfor %}
but I'm not sure how I'd work with this for inlining.
Could anyone provide any hints?
finnito
—
6 years ago
That didn't quite seem to work @ryanthompson - I'd be super stoked if you could whip something up! I'm all about minimising those HTTP requests ;)
ryanthompson
—
6 years ago
Can you whip up a feature request issue? I'll get on it tonight or tomorrow.
ryanthompson
—
6 years ago
Ill write something in shortly (tonight) and ping you.
ryanthompson
—
6 years ago
Have you tried just {{ asset_inline("scripts.js") }}
? Don't ask me why I didn't think of that before 😛 But that should suffice.
Try using
asset_urls
in the loop and thenasset_inline(url)
Otherwise I can make something for ya 😄