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

Idea for Multiple Delimiters (Easier JavaScript & CSS)

 
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
Metzen
Smarty Rookie


Joined: 16 Jan 2004
Posts: 6

PostPosted: Sat Mar 05, 2005 12:13 am    Post subject: Idea for Multiple Delimiters (Easier JavaScript & CSS) Reply with quote

{literal} tags work great usually, but when dynamically generating JavaScript or CSS code you find yourself in and out of literal mode about every other line.

So, here is my proposed solution:

Allow a secondary set of delimiters:

$smarty->left_delimiter = '{';
$smarty->right_delimiter = '}';
$smarty->left_delimiter_backup = '<!--{';
$smarty->right_delimiter_backup = '}-->';

Then when you are in JS or CSS code instead of surrounding it with {literal} and {/literal}, you surround it with {use_backup} and {/use_backup}, or whatever, which tells Smarty to ONLY parse the backup delimiters.

So you could use either set of delimiters anywhere in any of your templates, except in between {use_backup} and {/use_backup} where only the backup delimiters would be used.

Thoughts?
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Sat Mar 05, 2005 3:32 am    Post subject: Reply with quote

an easier method would be to write a prefilter that seeks out your javascript/css delimiters and replace them with {ldelim} {rdelim} just before compiling. Then there is no special syntax necessary in the template.
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