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

Changing Smarty delimiters on the fly.

 
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 -> General
View previous topic :: View next topic  
Author Message
Terry151151
Smarty Regular


Joined: 06 May 2010
Posts: 37
Location: Sydney Australia

PostPosted: Thu Jan 23, 2014 8:56 pm    Post subject: Changing Smarty delimiters on the fly. Reply with quote

As there seems to be only one set of possible left and right delimiters is it possible to change the delimiters on the fly?
What I want to do is change the delimiters to /*{ and }*/ inside JavaScript because I often append Smarty variables to function names and this messes up Dreamweaver's JavaScript syntaxing.
So I'd like make the variables to look like comments to Dreamweaver. I don't always want to change it to /*{ and }*/ as I would have hundreds of templates to change and would have to go back and test everything; BIG JOB.

What I'd like to be able to do is:

{JavaScript} // Delimiters change here to /*{ and }*/
...
function /*{FUNCTION_MOFIFIER}*/FunctionName()
{
}
...
...
{/JavaScript} // Delimiters revert back to { and }

Is this possible without messing up the template compiler?

Regards
Terry
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Thu Jan 23, 2014 11:09 pm    Post subject: Reply with quote

Use whatever alternate syntax you want like /*{ }*/ then create a prefilter that searches and replaces the /*{ with { and }*/ with } just before compile time.

Last edited by mohrt on Fri Jan 24, 2014 3:22 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Terry151151
Smarty Regular


Joined: 06 May 2010
Posts: 37
Location: Sydney Australia

PostPosted: Fri Jan 24, 2014 12:00 am    Post subject: Reply with quote

Thanks for the clue I think a pre-filter should work.

Regards
Terry
Back to top
View user's profile Send private message
Terry151151
Smarty Regular


Joined: 06 May 2010
Posts: 37
Location: Sydney Australia

PostPosted: Fri Jan 24, 2014 12:23 am    Post subject: Reply with quote

The the prefilter work great.

Thanks
Terry
Back to top
View user's profile Send private message
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 -> General 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