|
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 |
laidbak Smarty n00b
Joined: 04 Dec 2003 Posts: 3 Location: Long Beach, CA
|
Posted: Thu Dec 04, 2003 11:49 pm Post subject: Changing default replacement constructs |
|
|
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 |
|
laidbak Smarty n00b
Joined: 04 Dec 2003 Posts: 3 Location: Long Beach, CA
|
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Dec 05, 2003 4:45 pm Post subject: |
|
|
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 |
|
laidbak Smarty n00b
Joined: 04 Dec 2003 Posts: 3 Location: Long Beach, CA
|
Posted: Sat Dec 06, 2003 8:42 pm Post subject: |
|
|
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 |
|
|
|
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
|