RE: [SMARTY] determining syntactically valid templates
[email protected] ("Max Schwanekamp") Sun, 5 Nov 2006 17:32:02 -0800
| Newsgroups | php.smarty.general |
|---|---|
| Message-ID | <001301c70143$5e0968a0$680fa8c0@salamander> |
> From: Travis Low > 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. Probably the easiest method would be an iframe. Take the user's edited template, save it as a temp file, use an iframe to make a separate call to the server to get a rendered version, to be displayed via the iframe. Give the user a method on the containing page to accept/revise their edited content. If accepted, issue a request (either via regular post or via in background with an ajax request) to move the temp file to its permanent home. Obviously if the edited template results in a fatal parse error or something, the user will not "accept" the edit. Iframes are generally irritating, but this is one case where it might be worthwhile to 'em. -- Max Schwanekamp NeptuneWebworks.com