|
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 |
ilyalyu Smarty Regular
Joined: 03 Nov 2009 Posts: 72
|
Posted: Mon Mar 26, 2012 8:35 pm Post subject: Prefilters are applied twice with merge_compiled_includes on |
|
|
If I register prefilter and disable merge_compiled_includes: Code: | $smarty->merge_compiled_includes = false;
$smarty->registerFilter('pre', 'my_prefilter'); |
then this filter is executed once for each template or subtemplate.
If I register prefilter and enable merge_compiled_includes: Code: | $smarty->merge_compiled_includes = false;
$smarty->registerFilter('pre', 'my_prefilter'); |
then this filter is executed twice for subtemplates. For example, if my filter adds some text to the end of template, then this text will be added twice. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Mar 26, 2012 9:41 pm Post subject: |
|
|
Which version of Smarty do you use?
I can't reproduce this problem with the latest version (3.1. |
|
Back to top |
|
ilyalyu Smarty Regular
Joined: 03 Nov 2009 Posts: 72
|
Posted: Tue Mar 27, 2012 6:35 am Post subject: |
|
|
Code: | PHP:
include '../Smarty.class.php';
$smarty = new Smarty;
$smarty->compile_dir = '..';
$smarty->plugins_dir = '..';
$smarty->template_dir = '..';
$smarty->force_compile = true;
$smarty->merge_compiled_includes = true;
$smarty->registerFilter('pre', 'pre');
echo $smarty->fetch('a1.html');
echo $smarty->fetch('a2.html');
function pre($content) { return str_replace('word', '[word]', $content); }
=====
a1.html:
{include 'a3.html'}
=====
a2.html:
{include 'a3.html'}
=====
a3.html:
word
=====
Output:
[word][[word]]
=====
Expected output:
[word][word] |
I am using SVN version.
I guess the situation when you fetch several templates or create several Smarty objects in one PHP script was not tested enough. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Mar 27, 2012 2:47 pm Post subject: |
|
|
Yes, you are right if same subtemplate is compiled into different main templates.
This has been fixed in the SVN trunk and will later be included in Smarty 3.1.9 |
|
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
|