-
-
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 a new test to check if a block exists #1821
Comments
|
I would use |
I want to use it in combination with tag {# header.html.twig #}
<h{{ level|default(2) }} class="ui{% if 'icon' is block %} icon{% endif %} header">
{{ block('icon') }}
{% if 'subheader' is block %}
<div class="content">
{{ block('header') }}
<div class="sub header">{{ block('subheader') }}</div>
</div>
{% else %}
{{ block('header') }}
{% endif %}
</h{{ level|default(2) }}> Example of use: {# index.html.twig #}
{% embed 'header.html.twig' with { level: 3 } %}
{% block header %}My settings{% endblock %}
{% block icon %}<i class="settings icon"></i>{% endblock %}
{% endembed %}
{# <h3 class="ui icon header"><i class="settings icon"></i>My setting</h3> #}
{% embed 'header.html.twig' with { level: 4 } %}
{% block header %}My header{% endblock %}
{% endembed %}
{# <h4 class="ui header">My setting</h4> #}
{% embed 'header.html.twig' with { level: 2 } %}
{% block header %}My header{% endblock %}
{% block subheader %}My subheader{% endblock %}
{% endembed %}
{# <h2 class="ui header"><div class="content">My setting<div class="sub header">My subheader</div></div></h2> #} |
ok, can you submit a PR? |
fabpot
added a commit
that referenced
this issue
Nov 11, 2016
This PR was merged into the 1.x branch. Discussion ---------- Add "is defined" support for block() replaces #1831, fixes #1821 I think reusing the semantic of the `defined` test is more idiomatic and easily discoverable. /cc @hason Commits ------- 3ce06af added 'is defined' support for block() 4f013e0 Add test to check if a block exists
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Suggested names:
block name
block
defined block
The text was updated successfully, but these errors were encountered: