Re: [SMARTY] determining syntactically valid templates
Marcus Bointon <[email protected]> Sun, 5 Nov 2006 20:45:15 +0000
| Newsgroups | gmane.comp.php.smarty.general |
|---|---|
| Message-ID | <[email protected]> |
On 4 Nov 2006, at 04:23, 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? > > 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. I think the only way to do it is to render it in a separate PHP instance as it's quite easy to create a template that causes a fatal error, and there's nothing you can do to trap that within the current PHP instance. So either make a call to a url using file_get_contents or curl, or call it from a command line instance with exec() and friends, then check the output for any error messages. Marcus -- Marcus Bointon Synchromedia Limited: Creators of http://www.smartmessages.net/ [email protected] | http://www.synchromedia.co.uk/ -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php