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

Linebreaks in Output

 
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 Development
View previous topic :: View next topic  
Author Message
b.legt210
Smarty n00b


Joined: 15 Jan 2006
Posts: 1

PostPosted: Sun Jan 15, 2006 2:06 pm    Post subject: Linebreaks in Output Reply with quote

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


Joined: 25 Feb 2005
Posts: 14

PostPosted: Tue Oct 24, 2006 12:53 am    Post subject: Reply with quote

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


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Tue Oct 24, 2006 1:22 am    Post subject: Reply with quote

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:
Code:
foo/n
bar/n


You can just put an extra line feed in the source, yes?
Code:
{*foo*}/n
/n
....blah
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 Development 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