Skip to content

Block nested in IF statement won't work as expected #703

Description

@kucharovic

I have following scenario :

{% extends '::layout.html.twig' %}

{% block title "Some title" %}

{% if posts is empty %}
 {% block head %}
    {{ parent() }}
    <meta name="robots" content="noindex, follow">
 {% endblock head %}
{% endif %}

Expected result is that in header of page where aren't posts will appear meta tag. Actuall result is that meta tag appears in both types of page – with and without posts.

This “workaround” solve problem:

{% block head %}
    {{ parent() }}
    {% if posts is empty %}    
    <meta name="robots" content="noindex, follow">    
    {% endif %}
{% endblock head %}

Is this bug or just my misunderstanding?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions