|
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 |
jonyo Smarty Rookie
Joined: 14 Feb 2011 Posts: 16
|
Posted: Thu Apr 26, 2012 7:38 pm Post subject: 3.1.8 change (issue 71) breaks my post filter |
|
|
In my code, I use a post filter to add something to the header of the generated template code. The changes in 3.1.8 to fix issue 71 breaks this functionality, as it makes the post filters only get passed the compiled template contents, without the surrounding template code frame. So I am no longer able to add something where I need to in the compiled code.
Here is what I was previously doing, using this as a post filter (non-relevent parts removed for brevity):
Code: |
<?php
//file: postfilter.process_tags.php
function smarty_postfilter_process_tags ($source, Smarty_Internal_Template $template)
{
$extra = array();//this ends up being an array of useful info used elsewhere
$addSection=false;//gets set to true if we need to add the extra info...
//...
if ($addSection) {
//there is stuff to process
$section = '<?php $_smarty_tpl->used_tags = '.var_export($extra,1).'; ?>';
$source = str_replace('/*/%%SmartyHeaderCode%%*/?>','/*/%%SmartyHeaderCode%%*/?>'.$section,$source);
}
return $source;
} |
I'm not saying the change for issue 71 was bad, as it does make sense and my own use of post filters is more a fringe/specialized case. I'm asking if something could be done in a future version of Smarty to allow modifying what is generated by createTemplateCodeFrame(), without having to do too much of an ugly hack?
My own thought is maybe add a switch like $smarty->postFilterIncludeHeader = bool, where if it is true, it uses the old behavior and processes post filters after the call to createTemplateCodeFrame(). If false (which it would be set to by default), use the newer behaviour of doing post filters prior to calling createTemplateCodeFrame.
Also I wasn't sure if I should put this as an issue in google, or comment on the already resolved issue 71 to request it, or post it here or what. So if there is a better venue for my request please let me know...
Thanks! |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Thu Apr 26, 2012 9:50 pm Post subject: |
|
|
We do have already some plans for a possibillity to add meta data to compiled and cache files.
This will be available in the upcomming version 3.2. |
|
Back to top |
|
jonyo Smarty Rookie
Joined: 14 Feb 2011 Posts: 16
|
Posted: Sat Apr 28, 2012 8:33 pm Post subject: |
|
|
U.Tews wrote: | We do have already some plans for a possibillity to add meta data to compiled and cache files.
This will be available in the upcomming version 3.2. |
That's great, thanks for the info! I'll keep an eye out for it. |
|
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
|