From fe3c17f51f5f936cca66d404f5e1cb56a15f9512 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 8 Apr 2012 12:58:26 +0200 Subject: [PATCH] added a tip in the doc --- doc/recipes.rst | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) 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 -- 1.7.2.5