mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 11:27:00 +00:00
bug #1288 added an error message when trying to import an undefined block from a trait (fabpot)
This PR was merged into the master branch.
Discussion
----------
added an error message when trying to import an undefined block from a trait
Commits
-------
a2c6db7 added an error message when trying to import an undefined block from a trait
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
* 1.15.1 (2013-XX-XX)
|
||||
|
||||
* n/a
|
||||
* added an error message when trying to import an undefined block from a trait
|
||||
|
||||
* 1.15.0 (2013-12-06)
|
||||
|
||||
|
||||
@@ -170,6 +170,18 @@ class Twig_Node_Module extends Twig_Node
|
||||
|
||||
foreach ($trait->getNode('targets') as $key => $value) {
|
||||
$compiler
|
||||
->write(sprintf("if (!isset(\$_trait_%s_blocks[", $i))
|
||||
->string($key)
|
||||
->raw("])) {\n")
|
||||
->indent()
|
||||
->write("throw new Twig_Error_Runtime(sprintf('Block ")
|
||||
->string($key)
|
||||
->raw(" is not defined in trait ")
|
||||
->subcompile($trait->getNode('template'))
|
||||
->raw(".'));\n")
|
||||
->outdent()
|
||||
->write("}\n\n")
|
||||
|
||||
->write(sprintf("\$_trait_%s_blocks[", $i))
|
||||
->subcompile($value)
|
||||
->raw(sprintf("] = \$_trait_%s_blocks[", $i))
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
--TEST--
|
||||
Exception for an undefined trait
|
||||
--TEMPLATE--
|
||||
{% use 'foo' with foobar as bar %}
|
||||
--TEMPLATE(foo)--
|
||||
{% block bar %}
|
||||
{% endblock %}
|
||||
--EXCEPTION--
|
||||
Twig_Error_Runtime: Block "foobar" is not defined in trait "foo" in "index.twig".
|
||||
Reference in New Issue
Block a user