Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

html comments trouble

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
apollonin
Smarty Rookie


Joined: 08 Oct 2012
Posts: 9

PostPosted: Mon Oct 08, 2012 2:14 pm    Post subject: html comments trouble Reply with quote

Hi, we've migrated to smarty3 on our sytem, but got a trouble with old html comments in code.
Here is an example:
Code:
<!-- .column -->

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
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Mon Oct 08, 2012 9:07 pm    Post subject: Reply with quote

Smarty should not modify HTML tags.
Is some pre/post/output filter involved?

Which Smarty version do you use?
Back to top
View user's profile Send private message
apollonin
Smarty Rookie


Joined: 08 Oct 2012
Posts: 9

PostPosted: Tue Oct 09, 2012 10:00 am    Post subject: Reply with quote

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 Sad
Back to top
View user's profile Send private message
apollonin
Smarty Rookie


Joined: 08 Oct 2012
Posts: 9

PostPosted: Tue Oct 09, 2012 12:39 pm    Post subject: Reply with quote

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
View user's profile Send private message
apollonin
Smarty Rookie


Joined: 08 Oct 2012
Posts: 9

PostPosted: Tue Oct 09, 2012 1:04 pm    Post subject: Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Tue Oct 09, 2012 3:22 pm    Post subject: Reply with quote

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
View user's profile Send private message
apollonin
Smarty Rookie


Joined: 08 Oct 2012
Posts: 9

PostPosted: Tue Oct 09, 2012 4:08 pm    Post subject: Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Tue Oct 09, 2012 4:58 pm    Post subject: Reply with quote

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
View user's profile Send private message
apollonin
Smarty Rookie


Joined: 08 Oct 2012
Posts: 9

PostPosted: Wed Oct 10, 2012 9:51 am    Post subject: Reply with quote

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
View user's profile Send private message
apollonin
Smarty Rookie


Joined: 08 Oct 2012
Posts: 9

PostPosted: Wed Oct 10, 2012 10:49 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3 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