View previous topic :: View next topic |
Author |
Message |
apollonin Smarty Rookie
Joined: 08 Oct 2012 Posts: 9
|
Posted: Mon Oct 08, 2012 2:14 pm Post subject: html comments trouble |
|
|
Hi, we've migrated to smarty3 on our sytem, but got a trouble with old html comments in code.
Here is an example:
but after rendering, i've got smth like that:
Code: | </<!--
<!-- .column --> |
or like that:
Code: | </di<!--!-- .column --> |
it cuts nearby divs, and that's why my makeup has been broken... But at tha same time some others comments are rendering good.
Smarty 2 is ok on that code.
Have any ideas? |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Oct 08, 2012 9:07 pm Post subject: |
|
|
Smarty should not modify HTML tags.
Is some pre/post/output filter involved?
Which Smarty version do you use? |
|
Back to top |
|
apollonin Smarty Rookie
Joined: 08 Oct 2012 Posts: 9
|
Posted: Tue Oct 09, 2012 10:00 am Post subject: |
|
|
yes, we have pre filter, but it's a regular expression, that should not modify comments too.
Code: | function smarty_prefilter_g($tpl_source, Smarty_Internal_Template $template)
{
$tpl_source = preg_replace("/\{g(\}|\s+(.*?)\})(.*?)\{\/g\}/es",'"{g text=\"".str_replace("\"", \'\"\', stripslashes("$3"))."\" ".stripslashes("$2")."}"',$tpl_source);
return $tpl_source;
} |
this changes
{g prefix='bla'}text{/g}
to
{g text='text' prefix='bla'}
smarty version 3.1.12
And i can not get a regularity for this bug |
|
Back to top |
|
apollonin Smarty Rookie
Joined: 08 Oct 2012 Posts: 9
|
Posted: Tue Oct 09, 2012 12:39 pm Post subject: |
|
|
For example, i've got the code:
Code: | <div class="column section-title">
Leute aus Ihrer Nähe zu finden
</div>
<!-- .column --> |
After smarty renders it, i see:
Code: | <div class="column section-title">
Leute aus Ihrer Nähe zu finden
</div><!--- .column --> |
Or, and it is interesting, if source code is:
Code: | <div class="column section-title">
Leute aus Ihrer Nähe zu finden
Leute aus Ihrer Nähe zu finden
Leute aus Ihrer Nähe zu finden
</div>
<!-- .column --> |
The final html will be
Code: | <div class="column section-title">
Leute aus Ihrer Nähe zu finden
Leute aus Ihrer Nähe zu finden
Leute aus Ihrer Nähe zu finden
</di<!--!-- .column --> |
BUT!!
If code is:
Code: | <div class="column section-title">
some other word
</div>
<!-- .column --> |
everything is ok
Code: | <div class="column section-title">
some other word
</div>
<!-- .column --> |
And if i get smarty2 ckaas back to usage, it is ok too...
may be it is smth about encoding? |
|
Back to top |
|
apollonin Smarty Rookie
Joined: 08 Oct 2012 Posts: 9
|
Posted: Tue Oct 09, 2012 1:04 pm Post subject: |
|
|
and nother strange moment:
tha source code is
Code: | <div class="column section-title">
Unglücklich verheiratet.
</div>
<!-- .column --> |
but the result code is:
Code: | <div class="column section-title">
Unglücklich verheiratet.
</div><!--- .column --> |
so comment is on the same line as </div> in result. but at source - they are on the different lines oO.
If the text in div is "Unglcklich verheiratet." - everything is ok ... |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Oct 09, 2012 3:22 pm Post subject: |
|
|
I can't reproduce your problems.
can you have a look into the compiled template files in the template_c folder?
If you have caching enabled have also a look into the cache files |
|
Back to top |
|
apollonin Smarty Rookie
Joined: 08 Oct 2012 Posts: 9
|
Posted: Tue Oct 09, 2012 4:08 pm Post subject: |
|
|
hm...yes, i can.
here is source code:
Code: | <div class="column section-title comment_place">
Unglücklich verheiratet
</div>
<!-- .column --> |
here is html code in browser:
Code: | <div class="column section-title comment_place">
Unglücklich verheiratet
</div><!--- .column --> |
and here is smarty compiled:
Code: | <div class="column section-title comment_place">
Unglücklich verheiratet
</div>
<!-- .column --> |
seems to be good there oO. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Oct 09, 2012 4:58 pm Post subject: |
|
|
Okay, next test.
Any chance to use a PHP debugger? if yes use $foo=$smarty->fetch(...); instead of $smarty->display(...); and see whats in $foo.
running out of ideas.... |
|
Back to top |
|
apollonin Smarty Rookie
Joined: 08 Oct 2012 Posts: 9
|
Posted: Wed Oct 10, 2012 9:51 am Post subject: |
|
|
i'm using $smarty->fetch all over my project.
now i'm looking deeper into system, to find place where templates are breaking |
|
Back to top |
|
apollonin Smarty Rookie
Joined: 08 Oct 2012 Posts: 9
|
Posted: Wed Oct 10, 2012 10:49 am Post subject: |
|
|
So, finally, I have found the trouble.
It's in my system.
We recompose html styles and resources (considering they have comments). We use substr() function to do that.
So, when smarty2 compiles templates - everythong is ok. But if smarty 3 does the same, that function will not work correctly! I've replaced it with mb_substr() and it helped.
Thank you very much! You've directed my to the right way to see in compiled files, to find out, that it is not smarty problem at all! |
|
Back to top |
|
|