This commit is contained in:
Fabien Potencier
2024-01-25 08:09:49 +01:00
parent 0d3a283907
commit a93723eae2
2 changed files with 21 additions and 5 deletions
+10 -5
View File
@@ -155,6 +155,16 @@ abstract class YieldingTemplate extends Template
}
}
public function renderParentBlock($name, array $context, array $blocks = [])
{
$content = '';
foreach ($this->yieldParentBlock($name, $context, $blocks) as $data) {
$content .= $data;
}
return $content;
}
public function displayBlock($name, array $context, array $blocks = [], $useBlocks = true, Template $templateContext = null)
{
throw new RuntimeError(sprintf('Calling "%s" for block "%s" is not supported as "use_yield" is set to "true".', __METHOD__, $name), -1, $this->getSourceContext());
@@ -165,11 +175,6 @@ abstract class YieldingTemplate extends Template
throw new RuntimeError(sprintf('Calling "%s" for block "%s" is not supported as "use_yield" is set to "true".', __METHOD__, $name), -1, $this->getSourceContext());
}
public function renderParentBlock($name, array $context, array $blocks = [])
{
throw new RuntimeError(sprintf('Calling "%s" for block "%s" is not supported as "use_yield" is set to "true".', __METHOD__, $name), -1, $this->getSourceContext());
}
protected function displayWithErrorHandling(array $context, array $blocks = [])
{
throw new RuntimeError(sprintf('Calling "%s" is not supported as "use_yield" is set to "true".', __METHOD__), -1, $this->getSourceContext());
@@ -0,0 +1,11 @@
--TEST--
"block" calling parent() in a conditional expression
--TEMPLATE--
{% extends "parent.twig" %}
{% block label %}{{ parent() ?: 'foo' }}{% endblock %}
--TEMPLATE(parent.twig)--
{% block label %}PARENT_LABEL{% endblock %}
--DATA--
return []
--EXPECT--
PARENT_LABEL