Closed ThomasLandauer closed 7 months ago
Thanks for the PR 😍
Define the SYMFONY_ENDPOINT
environment variable:
# On Unix-like (BSD, Linux and macOS)
export SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes/flex/pull-1288/index.json
# On Windows
SET SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes/flex/pull-1288/index.json
Install the package(s) related to this recipe:
composer req 'symfony/flex:^1.16'
composer req 'symfony/asset-mapper:^6.4'
Don't forget to unset the SYMFONY_ENDPOINT
environment variable when done:
# On Unix-like (BSD, Linux and macOS)
unset SYMFONY_ENDPOINT
# On Windows
SET SYMFONY_ENDPOINT=
In order to help with the review stage, I'm in charge of computing the diff between the various versions of patched recipes. I'm going keep this comment up to date with any updates of the attached patch.
TL;DR; there is nothing to change
(and, personal opinion, i think this use case is a bit too specific to change the recipe anyway)
{# foo.html.twig #}
{% block javascripts %}
{% block importmap %} -importmap- {% endblock %}
--important js--
{% endblock %}
{# bar.html.twig #}
{% extends 'foo.html.twig' %}
Result:
-import map
--important js--
{# bar.html.twig #}
{% extends 'foo.html.twig' %}
{% block importmap %} -another import map {% endblock %}
Result:
-another import map
--important js--
{# bar.html.twig #}
{% extends 'foo.html.twig' %}
{% block javascripts %} --another important js-- {% endblock %}
Result:
--another important js--
{# bar.html.twig #}
{% extends 'foo.html.twig' %}
{% block javascripts %}
{{ parent() }}
--another important js--
{% endblock %}
Result:
-importmap-
--important js--
--another important js--
{# bar.html.twig #}
{% extends 'foo.html.twig' %}
{% block importmap %}
- another importmap
{% endblock %}
{% block javascripts %}
{{ parent() }}
--another important js--
{% endblock %}
Result:
- another importmap
--important js--
--another important js--
Thanks, you're right! I thought it's required/recommended to override the blocks in the same nesting situation as they are defined:
{% block javascripts %}
{% block importmap %} - another importmap- {% endblock %}
{{ parent() }}
--another important js--
{% endblock %}
Which then lead to my problem above.
So I'm closing here, since this is a general Twig misunderstanding, unrelated to this recipe.
Anyway, I still can't see any real reason why {% block importmap %}
should live inside {% block javascripts %}
- so I guess it's just a matter of personal taste.
@weaverryan Disclaimer: I'm not sure about this - especially I didn't check if
before_target
is actually doing what I want ;-)Here's the scenario I'm talking about:
Now how can I get the other important JavaScript onto
some_page
? IMO only by doing:But this will also render the importmap twice. Right?
My solution: Move
{% block importmap %}
outside of{% block javascripts %}
. What do you think?If you merge this, the code block at https://symfony.com/doc/6.4/frontend/asset_mapper.html#installation would need to be updated again... :-)