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 default replacement constructs

 
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 -> Tips and Tricks
View previous topic :: View next topic  
Author Message
laidbak
Smarty n00b


Joined: 04 Dec 2003
Posts: 3
Location: Long Beach, CA

PostPosted: Thu Dec 04, 2003 11:49 pm    Post subject: Changing default replacement constructs Reply with quote

I'm just starting to take another look at smarty after previewing it a couple years ago.

I'm looking to really pound it and see how well it can do, however, I'd like to know if anyone already has experience with the following modifications.

I'd like to wrap looping constructs with the following tags:

<!--[$BLOCK]-->

and I'd like to see simple variable replacement work like:

{{$VARNAME}}

Is it possible to configure smarty like this? A quick look at the docs and I know I can do one or the other, however, is there a simple way to get both?

Keep in mind I don't know the internals of smarty at the moment besides reading through the manual for about an hour last night.
_________________
Wil Moore III
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
laidbak
Smarty n00b


Joined: 04 Dec 2003
Posts: 3
Location: Long Beach, CA

PostPosted: Fri Dec 05, 2003 12:23 am    Post subject: Reply with quote

Well part of my question has been answered by this thread: http://www.phpinsider.com/smarty-forum/viewtopic.php?t=233 , however, I see the problem has not been 100% resolved.
_________________
Wil Moore III
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
mohrt
Administrator


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

PostPosted: Fri Dec 05, 2003 4:45 pm    Post subject: Reply with quote

I think it has been resolved. Use a prefilter to convert your special tags to the tags that smarty expects. Smarty only uses one set of delimiters, and that won't be changing any time soon. Using a prefilter doesn't cause a performance hit (just a tiny bit at compile time), and this keeps the tokenizer simple.

This has been brought up often enough, maybe we could supply an official prefilter and explain in the documentation how to use it.
Back to top
View user's profile Send private message Visit poster's website
laidbak
Smarty n00b


Joined: 04 Dec 2003
Posts: 3
Location: Long Beach, CA

PostPosted: Sat Dec 06, 2003 8:42 pm    Post subject: Reply with quote

What about:
Claas wrote:
...
function smarty_prefilter_delimiters(&$smarty,$code){
$ld = $smarty->left_delimiter;
$rd = $smarty->right_delimiter;
return preg_replace("#<\!--($ld.?$ld)-->#U",'\1',$code);
}

works fine so far but:
prefilter is done before {include} subtitution.
so the prefilter doesnt work in included files...

_________________
Wil Moore III
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
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 -> Tips and Tricks 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