Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Prefilters

 
Post new topic   Reply to topic    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
ilyalyu
Smarty Regular


Joined: 03 Nov 2009
Posts: 72

PostPosted: Tue Oct 23, 2012 2:51 pm    Post subject: Prefilters Reply with quote

In some cases I get different result when:
1. My template contains code X and I have prefilter that converts code X to code Y
and when:
2. My template contains code Y and no prefilter
Why don't you apply prefilter right after you get content with getContent function? I think that in this case if you get code Y after prefilter you will get exactly the same result as if you had code Y initially and did not apply any prefilters.

To be more specific, I am trying to redefine function delcared in base template. For this I use blocks:
base template: {block a}{function a}code version 1{/function}{/block}
child template: {block a}{function a}code version 2{/function}{/block}
This works as I expect (function is redefined and outputs "code version 2" instead of "code version 1"). However, adding {block} to every function manually is inconvenient, so I have written prefilter that does this work (i.e. it adds block to every function definition). So now I have:
base template: {function a}code version 1{/function}
child template: {function a}code version 2{/function}
and prefilter adds blocks, so that the code after prefilters is the same as above. However, this does not work. So I get different result, though the code after applying prefilters is the same in both cases.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 4507
Location: Hamburg / Germany

PostPosted: Tue Oct 23, 2012 6:31 pm    Post subject: Reply with quote

I'm currently out of office for a week and will look into it when I'm back.
But you may be right that {block} tags of inheritance are processed before the prefilter so you can't currently add {block} tags by the filter.
Back to top
View user's profile Send private message
ilyalyu
Smarty Regular


Joined: 03 Nov 2009
Posts: 72

PostPosted: Thu Nov 15, 2012 8:33 pm    Post subject: Reply with quote

Any news here?
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 4507
Location: Hamburg / Germany

PostPosted: Sat Nov 17, 2012 12:34 pm    Post subject: Reply with quote

This problem will not occur in the upcomming major release of 3.2 as the internals of template inheritance have been completely rewritten.

I will try to implement a fix for 3.1 but that is not as easy as running the prefilters at the time of getContent. Because of the internals this would cause that the prefilters to run twice in other cases....
Back to top
View user's profile Send private message
ilyalyu
Smarty Regular


Joined: 03 Nov 2009
Posts: 72

PostPosted: Sat Nov 17, 2012 3:52 pm    Post subject: Reply with quote

I have already found temporary fix. So, I can wait for the 3.2 version.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Bugs 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