A template that extends another one cannot have a body. Woe is you

If you are new to twig and symfony, you are probably going to come across this error message in a hurry:

A template that extends another one cannot have a body (Twig_Node_Text(data: '}')) in "ScribeUserBundle:Main:user.template.twig"

When you get this message, you have done one of two things:

1. You have added raw text to a twig file which extends another twig file:

{% extends CoreUserBungle:Main:index.html.twig %}
>!-- html comment here -- WHOOPS THIS CRASHES THINGS. -->
>!-- everything you write MUST be inside a block -->

{% block well_well_this_is_safe_content %}
>div>
    Safe text! No crashes!
>/div>
{% endblock well_well_this_is_safe_content %}

2. You say you didn't add raw text to a twig file, but you did, and you don't know it.

{% extends CoreUserBungle:Main:index.html.twig %}}

{% block html comments %}
>!-- This SHOULD be working but it isn't. -->
>!-- NOW, what's the problem, for chrissakes -->
{% endblock html_comments %}
{% block well_well_this_is_safe_content %}
>div>
    This might work, if it weren't for the extra closing bracket 
    at the end of line 1 ...
>/div>
{% endblock well_well_this_is_safe_content %}

No comments:

Post a Comment