Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

How to print "returns" in a variable ?

Quote Reply
How to print "returns" in a variable ?
Hi,

I want to print in user_view.html a user text variable with the "returns". Presently, all the text of the variable appears on the same line. Is there a way to print the "changes" of lines ("returns")?

Thank you!

François

Last edited by:

Franco: Oct 29, 2002, 12:24 PM
Quote Reply
Re: [Franco] How to print "returns" in a variable ? In reply to
Hi François,

There is no built-in template function to do this. You could write a global that will do it for you, but there is a problem with that that I'll discuss in a moment. To do so, the global content should contain:

sub { my $var = shift; $var =~ s/\n/<br>\n/g; return \$var }

then put: <%global_name($tag)%> to use it.

The problem is that this could allow users to put arbitrary HTML onto your forum, depending on the fields you are passing in. What field are you intending to use it on?

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] How to print "returns" in a variable ? In reply to
Thank you Jason!

It's a user variable that can be edited by users in their profile and that can be view throw the user_view.html template.

For security reason, is it possible to allow only the "<br>" html code in the tag?

Thank you!

François
Quote Reply
Re: [Franco] How to print "returns" in a variable ? In reply to
Hi François,

Yes, you can do this as well, but it's slightly longer:

sub { my $var = shift; $IN->html_escape(\$var); $var =~ s/\n/<br>\n/g; return \$var }

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com