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

{strip} render has no space between attributes

 
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
timeceeper
Smarty n00b


Joined: 12 May 2021
Posts: 2

PostPosted: Thu May 20, 2021 2:43 pm    Post subject: {strip} render has no space between attributes Reply with quote

Hello,

i have a problem with {strip} on templates.
i use Smatry Version '3.1.39'

I have the following template: (Editor Indent with 4 spaces)

Code:
{strip}
<div id="1"
    class="foo foo-{$class}"
    data-id="{$data_id}"
    style="color:red">
    <div class="bar">{$content}</div>
</div>
{/strip}


which is rendered to:

Code:
<div id="1" class="foo foo-first"data-id="foo-first"style="color:red"><div class="bar">hello world!</div></div>


Why are there missing spaces in front of 'data-id' and 'style'?
or why is the space in front of 'class'?

I dont want to write all html attributes in one line.


I have looked in "modifiercompiler.strip.php"
It is only a
Code:
preg_replace "!\s+!"
with one space

Hope someone can help.


With best regards
Andreas
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Fri May 21, 2021 7:19 pm    Post subject: Reply with quote

{strip} is a compile-time modifier. The problem is caused by the fact PHP eats the end-of-line mark after "?>" tag. Look into compiled template to understand it.

The solution is to either include extra lines between attributes or use HTML post-filter (like tidy) instead of {strip} (the latter would be a MUCH better approach). Alternatively, just enable HTTP compression already.
Back to top
View user's profile Send private message
timeceeper
Smarty n00b


Joined: 12 May 2021
Posts: 2

PostPosted: Sat May 22, 2021 10:27 am    Post subject: Reply with quote

Hello,

thank you.
So the space in front of 'class' is because there is no variable in the line with the 'id'?

that make sense.. sorry i haven't looked at the compiled file before.

i will look for another solution.
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