Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Skip or error in a template parser

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Feature Requests
View previous topic :: View next topic  
Author Message
bimal
Smarty Elite


Joined: 19 Apr 2007
Posts: 423

PostPosted: Sat Mar 14, 2009 5:19 am    Post subject: Skip or error in a template parser Reply with quote

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
View user's profile Send private message Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Sat Mar 14, 2009 3:50 pm    Post subject: Reply with quote

Smarty 3 does handle { and } differently. If there is white space on each side, they are ignored.
Back to top
View user's profile Send private message Visit poster's website
bimal
Smarty Elite


Joined: 19 Apr 2007
Posts: 423

PostPosted: Sat Mar 14, 2009 5:09 pm    Post subject: Cute idea Reply with quote

Cute idea!

When do you plan to put it back on Smarty download, instead of the google code svn?
Back to top
View user's profile Send private message Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Sat Mar 14, 2009 5:56 pm    Post subject: Reply with quote

SVN is the only place Smarty 3 lives until it gets to beta at least.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Feature Requests All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP