I tried removing as much whitespace as possible from some templates (via regex) and found some weird behaviour which I believe to be a bug.
As far as I can tell, if a template extends another one and defines a block inside another tag (e.g. an if), and there is no whitespace present, it'll throw an error.
Example:
foo.twig may be completely empty, it doesn't seem to matter
foobar.twig looks like this:
{% extends 'foo.twig' %}
{% if true %}
{% block foobar 'asdf' %}
{% endif %}
Note that there is no whitespace between the if, block and endif tags except for those two newlines. If I add any whitespace in between those tags, e.g. a space character or another newline, this error does not occur. This is why I call it a bug.
Also, if I remove those two newlines so I get everything in one line, I still get the error.
Error: An exception has been thrown during the compilation of a template ("Node "1" does not exist for Node "Twig_Node".") in "path/to/foobar.twig".
Using a different tag yields a slightly different error, for example spaceless:
{% extends 'foo.twig' %}
{% spaceless %}
{% block foobar 'asdf' %}
{% endspaceless %}
Error: An exception has been thrown during the compilation of a template ("Node "body" does not exist for Node "Twig_Node_Spaceless".") in "path/to/foobar.twig".
I haven't tried any other tags since very few make sense in this context (probably only if).
Tested on Twig v1.18.1 in a Laravel v4.2.17 project via @rcrowe's TwigBridge v0.6.1
Let me know if you need anything else.
I tried removing as much whitespace as possible from some templates (via regex) and found some weird behaviour which I believe to be a bug.
As far as I can tell, if a template extends another one and defines a block inside another tag (e.g. an if), and there is no whitespace present, it'll throw an error.
Example:
foo.twigmay be completely empty, it doesn't seem to matterfoobar.twiglooks like this:{% extends 'foo.twig' %} {% if true %} {% block foobar 'asdf' %} {% endif %}Note that there is no whitespace between the
if,blockandendiftags except for those two newlines. If I add any whitespace in between those tags, e.g. a space character or another newline, this error does not occur. This is why I call it a bug.Also, if I remove those two newlines so I get everything in one line, I still get the error.
Error:
An exception has been thrown during the compilation of a template ("Node "1" does not exist for Node "Twig_Node".") in "path/to/foobar.twig".Using a different tag yields a slightly different error, for example
spaceless:{% extends 'foo.twig' %} {% spaceless %} {% block foobar 'asdf' %} {% endspaceless %}Error:
An exception has been thrown during the compilation of a template ("Node "body" does not exist for Node "Twig_Node_Spaceless".") in "path/to/foobar.twig".I haven't tried any other tags since very few make sense in this context (probably only
if).Tested on Twig v1.18.1 in a Laravel v4.2.17 project via @rcrowe's TwigBridge v0.6.1
Let me know if you need anything else.