|
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 |
b.legt210 Smarty n00b
Joined: 15 Jan 2006 Posts: 1
|
Posted: Sun Jan 15, 2006 2:06 pm Post subject: Linebreaks in Output |
|
|
while useing comments or foreach-loops in templates, smarty "loses" linebreaks in output. Didn't understand a word?? so here's an example:
When you have something like this in your template:
<tab>{* TEST *}\n
<tab>Text after Comment
Smarty outputs:
<tab><tab>Text after Comment
So if you "structure" your templates, the output ist often "unreadable" because the linebreak after comments (and foreach and maybe other elements) are missing. For me it would look much better if only the comment-element (and foreach-element) would be replaced in the output BUT NOT THE FOLLOWING \n (linebreak).
The upper example should output:
<tab>\n
<tab>Text after Comment
Stephan |
|
Back to top |
|
Rikaelus Smarty Rookie
Joined: 25 Feb 2005 Posts: 14
|
Posted: Tue Oct 24, 2006 12:53 am Post subject: |
|
|
I faced this same problem and unfortunately, even after bouncing it off some heads in #smarty, came to the conclusion that it's easiest to pass Smarty an endline. Yep, pass a text to Smarty that only contains an endline. So now I have {$N} where I want newlines explicitely at.
Far from an ideal solution, but it works. Just one of those things I never had to face till I was making a template that got passed to the user as text and not HTML. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Tue Oct 24, 2006 1:22 am Post subject: |
|
|
You really want:
Code: | {* foo *}/n
{if $foo}/n
foo/n
{/if}/n
{* bar *}/n
{if $bar}/n
bar/n
{/if}/n |
to produce
Code: | /n
/n
foo/n
/n
/n
/n
bar/n
/n |
?
I think not. I think most of us would want:
You can just put an extra line feed in the source, yes?
Code: | {*foo*}/n
/n
....blah |
|
|
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
|