mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-30 03:57:21 +00:00
do not clean up whitespace text nodes inside if tags
This commit is contained in:
committed by
Fabien Potencier
parent
6cd1473d65
commit
c8ec092ceb
+4
-1
@@ -50,8 +50,11 @@ class IfNode extends Node
|
||||
->subcompile($this->getNode('tests')->getNode($i))
|
||||
->raw(") {\n")
|
||||
->indent()
|
||||
->subcompile($this->getNode('tests')->getNode($i + 1))
|
||||
;
|
||||
// The node might not exists if the content is empty
|
||||
if ($this->getNode('tests')->hasNode($i + 1)) {
|
||||
$compiler->subcompile($this->getNode('tests')->getNode($i + 1));
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->hasNode('else')) {
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
empty "if" body in child template
|
||||
--TEMPLATE--
|
||||
{% extends 'base.twig' %}
|
||||
|
||||
{% set foo = '' %}
|
||||
|
||||
{% if a is defined %}
|
||||
|
||||
{% else %}
|
||||
{% set foo = 'NOTHING' %}
|
||||
{% endif %}
|
||||
|
||||
{% if a is defined %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% if a is defined %}
|
||||
{% set foo = 'NOTHING' %}
|
||||
{% else %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% block content %}
|
||||
{{ foo }}
|
||||
{% endblock %}
|
||||
--TEMPLATE(base.twig)--
|
||||
{% block content %}{% endblock %}
|
||||
--DATA--
|
||||
return []
|
||||
--EXPECT--
|
||||
NOTHING
|
||||
Reference in New Issue
Block a user