-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the render function, deprecate the include one #4434
base: 3.x
Are you sure you want to change the base?
Conversation
cfd3254
to
8c1dac8
Compare
Maybe it would be good to also deprecate the |
8c1dac8
to
e62c09c
Compare
@fabpot wanted to give some feedback. I really like the new include decision without context by default. Even I'm not a fan of renaming it Typically looks like this: {# overlay.html.twig #}
<dialog>
<h3>
{% block title %}{% endblock %}
</h3>
<div>
{% block content %}{% endblock %}
</div>
</dialog> {# using.html.twig #}
{% set title = 'Title' %}
{% set content = 'Content' %}
{% embed "overlay.html.twig" only %}
{% block title %}
{{ title }} {# not available #}
{% endblock %}
{% block content %}
<div>
{{ content }} {# not available #}
</div>
{% endblock %}
{% endembed %} To get this work I need give the variables also to overlay.html.twig which may have similar variables defined. {# using.html.twig #}
{% set title = 'Title' %}
{% set content = 'Content' %}
{% embed "overlay.html.twig" {title: title, content: content} only %}
{% block title %}
{{ title }}
{% endblock %}
{% block content %}
<div>
{{ content }}
</div>
{% endblock %}
{% endembed %} So it is a little bit strange. That I need to give the variables to the {# using.html.twig #}
{% set title = 'Title' %}
{% set content = 'Content' %}
{% embed "overlay.html.twig" only %}
{% block title %}
{{ title }} {# still have access to this one #}
{% endblock %}
{% block content %}
<div>
{{ content }} {# still have access to this one #}
</div>
{% endblock %}
{% endembed %} Another solution would be maybe make it transparency on the embed block e.g.: {# using.html.twig #}
{% set title = 'Title' %}
{% set content = 'Content' %}
{% embed "overlay.html.twig" only %}
{% embedblock title with { title: title} %}
{{ title }}
{% endembedblock %}
{% embedblock content with { content: content} %}
<div>
{{ content }}
</div>
{% endembedblock %}
{% endembed %} I hope I did make it understandable where the issues with the embed tag is. |
|
@alexander-schranz the Your proposed syntax will not work, because blocks are rendered with the context from the caller (i.e. the parent template). they have no way to access the context of the place including the template. |
@stof I understand that it is a technical challange to change that behaviour. Just wanted to give feedback that from end user perspective it just felled for me strange how it behaves currently. |
@fabpot is the new terminology |
e62c09c
to
9807713
Compare
No description provided.