Twig: Unknown "endblock" tag

Created on 30 Jan 2016  路  6Comments  路  Source: twigphp/Twig

I use
{% block ibox-title %}{% endblock %}
can not use -

Most helpful comment

Hi,
From the docs;

Block names should consist of alphanumeric characters, and underscores. Dashes are not permitted.

So your observation is correct and a known system limitation.

All 6 comments

Hi,
From the docs;

Block names should consist of alphanumeric characters, and underscores. Dashes are not permitted.

So your observation is correct and a known system limitation.

I just ran into the same issue. The error message should be more clear, e.g. "invalid block name ...".

Well, the point is that {% block ibox-title %} alone is valid. It is the same than {% block ibox -title %} i.e. creating a block named ibox with its content set by the expression -title (in which case the block tag does not expect a closing tag)

@stof while it makes sense, the behavior is somewhat unexpected.

To make things more clear, the shortcut notation could require a blank space between the block name and its content.

{% block ibox-title %} would be invalid
{% block ibox -title %} would still be valid

@davidgorges this would be very hard to implement, because spaces are optional and insignificant in Twig (there are cases where you usually use spaces to be sure that 2 things are considered as separate tokens by the lexer, but most of these cases could also use parenthesis to delimit one of the expression rather than separating them with spaces). Spaces are the mostly for readability.

Closing as there is unfortunately nothing we can do to fix this easily.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mmarton picture mmarton  路  4Comments

ericmorand picture ericmorand  路  4Comments

CriseX picture CriseX  路  4Comments

dvladimirov77 picture dvladimirov77  路  5Comments

yguedidi picture yguedidi  路  4Comments