Re: Converting newlines to <br /> tags

Bill Ward <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.template-toolkit
Message-ID <CAKGT8Wpd73mcXvjQmvMHr0LBjm8MWPiw9uqTuM4jA7AnPfCuWg@mail.gmail.com>
Your tip works ...

I tried changing "HTML.escape(x)" "x | html" but it isn't working
everywhere. I have, for example, some places where I have:
<td>[% HTML.escape(b.affiliations.0) || "&nbsp;"  %]</td>

but changing it to:

<td>[% b.affiliations.0 | html || "&nbsp;"  %]</td>
or
<td>[% (b.affiliations.0 | html) || "&nbsp;"  %]</td>
does not work; I get a parse error in both cases.

I could just go back to HTML.escape() and in this case I have no need for
the html_line_break ... but if I ever needed both the &nbsp thing as well
as the line break thing, how could that be done?

On Sun, Feb 12, 2012 at 7:39 PM, Bill Ward <[email protected]> wrote:

> No. And " | html" is a lot more concise than what I've been using too.
> Thanks!
>
>
> On Sun, Feb 12, 2012 at 7:17 PM, Tobias Kremer <[email protected]>wrote:
>
>> Hi Bill,
>>
>> have you tried this?
>>
>> [% s.contribution | html | html_line_break %]
>>
>> Taken from:
>>
>>
>> http://template-toolkit.org/docs/manual/Filters.html#section_html_line_break
>>
>>
>> Hope this helps!
>> --Toby
>>
>>
>> On 12.02.2012, at 23:45, Bill Ward <[email protected]> wrote:
>>
>> Is there a filter that will convert \n characters to <br /> tags as well
>> as converting other special characters to HTML entities?
>>
>> Currently I display the data using this code:
>>
>> <td>[% HTML.escape(s.contribution) %]</td>
>>
>> if I change the \n to <br /> in the Perl code, that gets converted to
>> &lt;br /&gt; in the output naturally. I don't want to put actual Perl code
>> into the template. I don't see anything in Template::Plugin::HTML that
>> might help.
>>
>> --
>> Check out my LEGO blog at http://www.brickpile.com
>> Follow/friend me: facebook.com/billward • flickr.com/photos/billward •
>> twitter.com/williamward
>>
>> _______________________________________________
>> templates mailing list
>> [email protected]
>> http://mail.template-toolkit.org/mailman/listinfo/templates
>>
>>
>
>
> --
> Check out my LEGO blog at http://www.brickpile.com
> Follow/friend me: facebook.com/billward • flickr.com/photos/billward •
> twitter.com/williamward
>
>


-- 
Check out my LEGO blog at http://www.brickpile.com
Follow/friend me: facebook.com/billward • flickr.com/photos/billward •
twitter.com/williamward

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.