From: Fabien Potencier Date: Sun, 8 Apr 2012 10:58:26 +0000 (+0200) Subject: added a tip in the doc X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=fe3c17f51f5f936cca66d404f5e1cb56a15f9512;p=web%2Fkonrad%2Ftwig.git added a tip in the doc --- diff --git a/doc/recipes.rst b/doc/recipes.rst index 089ed40..ff4678a 100644 --- a/doc/recipes.rst +++ b/doc/recipes.rst @@ -256,6 +256,19 @@ how you can do it:: // $template contains one or more syntax errors } +If you iterate over a set of files, you can pass the filename to the +``tokenize()`` method to get the filename in the exception message:: + + foreach ($files as $file) { + try { + $twig->parse($twig->tokenize($template, $file)); + + // the $template is valid + } catch (Twig_Error_Syntax $e) { + // $template contains one or more syntax errors + } + } + .. note:: This method won't catch any sandbox policy violations because the policy