|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
bimal Smarty Elite
Joined: 19 Apr 2007 Posts: 423
|
Posted: Sat Mar 14, 2009 5:19 am Post subject: Skip or error in a template parser |
|
|
Here is one more idea to make best out of Smarty features.
For example, if a function call does not exist in the smarty enviornment of an application, the complier should ignore it silently.
Unless we FORCE smarty show an error in such case (this feature too needs to be added), smarty displays the code itself, instead of trying to parse it.
This helps writing css and javascripts naturally <even though, externalizing them is a better option; we can not skip emebdding for sensitive applications>
Here would be the scenerio:
Code: | $smarty->show_compiler_error = true; # ONLY FOR DEVELOPMENT. |
A production level setupu would be:
Code: | $smarty->show_compiler_error = ($_SERVER['SERVER_NAME']=='localhost')?true:false;
... |
and, if a javascript snippet or anything else with {...} exists in the template, if will determine whether to show the tag itself or, try to parse it, based on the compiler error flag setup.
Examples:
Code: | {include file='xyz.tpl'} | would complie.
Code: | <script>
function error()
{
...
}
</script> | would display the text as it is.
Some custom template-function calls like
Code: | {nonexistent var1='..'} | would display as it-is. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sat Mar 14, 2009 3:50 pm Post subject: |
|
|
Smarty 3 does handle { and } differently. If there is white space on each side, they are ignored. |
|
Back to top |
|
bimal Smarty Elite
Joined: 19 Apr 2007 Posts: 423
|
Posted: Sat Mar 14, 2009 5:09 pm Post subject: Cute idea |
|
|
Cute idea!
When do you plan to put it back on Smarty download, instead of the google code svn? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sat Mar 14, 2009 5:56 pm Post subject: |
|
|
SVN is the only place Smarty 3 lives until it gets to beta at least. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|