Re: [SMARTY] determining syntactically valid templates
| From: | messju mohr | Date: | Mon, 06 Nov 2006 10:13:37 +0000 |
| Subject: | Re: [SMARTY] determining syntactically valid templates | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-13558@lists.php.net to get a copy of this message | ||
On Fri, Nov 03, 2006 at 11:23:59PM -0500, Travis Low wrote:
> Hello. Is there a function available, or can anyone think of a good trick
> to determine if a template is syntactically valid, without having to render
> it?
unfortunately there is no convenient api function for this.
maybe you can compile the template like eval does:
$smarty->_compile_source('checking template', $source, $php_code)
caveats:
- compiler-function are executed, of course (this may have undesired
side effects)
- maybe you should additionally check the php-syntax of $php_code
since there may be errors in the template that smarty fails to catch
(that should not be, but it happend reguarly)
greetins
messju
> I'd like to provide my clients a means to do simple template edits. But
> before saving the template, I'd like to be able to pass the template as a
> string to some function (or pass the filename/path to a function) and have
> the function return TRUE if the template is syntactically valid, FALSE
> otherwise.
>
> cheers,
>
> Travis
>
> --
> Travis Low
> <mailto:travis@dawnstar.com>
> <http://www.dawnstar.com>
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php