|
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 |
timeceeper Smarty n00b
Joined: 12 May 2021 Posts: 2
|
Posted: Thu May 20, 2021 2:43 pm Post subject: {strip} render has no space between attributes |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Fri May 21, 2021 7:19 pm Post subject: |
|
|
{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 |
|
timeceeper Smarty n00b
Joined: 12 May 2021 Posts: 2
|
Posted: Sat May 22, 2021 10:27 am Post subject: |
|
|
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 |
|
|
|
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
|