* removed support for {{ 1 < i < 3 }} (use {{ i > 1 and i < 3 }} instead)
Changes:
+ * made error message for strict variables more useful
* changed trans tag to accept any variable for the plural count
* fixed sandbox mode (__toString() method check was not enforced if called implicitly from complex statements)
* added the ** (power) operator
} elseif ('_charset' === $this->getAttribute('name')) {
$compiler->raw('$this->getEnvironment()->getCharset()');
} elseif ($compiler->getEnvironment()->isStrictVariables()) {
- $compiler->raw(sprintf('$this->getContext($context, \'%s\')', $this->getAttribute('name'), $this->getAttribute('name')));
+ $compiler->raw(sprintf('$this->getContext($context, \'%s\', \'%s\')', $this->getAttribute('name'), $this->lineno));
} else {
$compiler->raw(sprintf('(isset($context[\'%s\']) ? $context[\'%s\'] : null)', $this->getAttribute('name'), $this->getAttribute('name')));
}
$this->compileMacros($compiler);
+ $this->compileGetTemplateName($compiler);
+
$this->compileClassFooter($compiler);
}
{
$compiler->subcompile($this->getNode('macros'));
}
+
+ protected function compileGetTemplateName($compiler)
+ {
+ $compiler
+ ->write("public function getTemplateName()\n", "{\n")
+ ->indent()
+ ->write('return ')
+ ->repr($this->getAttribute('filename'))
+ ->raw(";\n")
+ ->outdent()
+ ->write("}\n")
+ ;
+ }
}
$this->blocks = array();
}
+ public function getTemplateName()
+ {
+ return 'n/a';
+ }
+
public function getEnvironment()
{
return $this->env;
return ob_get_clean();
}
- protected function getContext($context, $item)
+ protected function getContext($context, $item, $line = -1)
{
if (!array_key_exists($item, $context)) {
- throw new Twig_Error_Runtime(sprintf('Variable "%s" does not exist.', $item));
+ throw new Twig_Error_Runtime(sprintf('Variable "%s" does not exist in "%s" at line %s.', $item, $this->getTemplateName(), $line));
}
return $context[$item];
$env = new Twig_Environment(null, array('strict_variables' => true));
return array(
- array($node, '$this->getContext($context, \'foo\')', $env),
+ array($node, '$this->getContext($context, \'foo\', \'0\')', $env),
array($node, '(isset($context[\'foo\']) ? $context[\'foo\'] : null)'),
array($self, '$this'),
array($context, '$context'),
echo "foo";
}
+ public function getTemplateName()
+ {
+ return "foo.twig";
+ }
}
EOF
, $twig);
\$this->getParent(\$context)->display(\$context, array_merge(\$this->blocks, \$blocks));
}
+ public function getTemplateName()
+ {
+ return "foo.twig";
+ }
}
EOF
, $twig);
\$this->getParent(\$context)->display(\$context, array_merge(\$this->blocks, \$blocks));
}
+ public function getTemplateName()
+ {
+ return "foo.twig";
+ }
}
EOF
, $twig);
);
}
+ public function getTemplateName()
+ {
+ return "foo.twig";
+ }
}
EOF
, $twig);
\$this->parent->checkSecurity();
}
+ public function getTemplateName()
+ {
+ return "foo.twig";
+ }
}
EOF
, $twig);