Hi,
I just saw that somebody shared this pluggin,
http://marc.theaimsgroup.com/?l=smarty-general&m=104378865428811&w=2
which I haven't tried yet. A while back, I struggled writing something
similar on my own that I'm
not too proud of because it still doesn't cover all cases (regex isn't my
favorite thing on earth)
Anyhow, I think that perhaps both modifier pluggins should merge into
something
like this
function smarty_modifier_htmlize($string, $what = 'all')
where $what could be 'nl2br', 'href, 'mailto' or 'all'.
because I think that it's very likely that if someone needs to wrap
www.foo.com in an
<a href ...>, chances are that they might one to turn every new line into a
<br>
Perhaps HTMLizing text should be part of the standard (out of the box),
plug-in repository.
Adios,
ubaldo
www.loquo.com
----- Original Message -----
From: "Paul Lockaby" <***@vt.edu>
To: "Paul Lockaby" <***@vt.edu>
Cc: "gawan" <***@gawan.net>; <smarty-***@lists.php.net>
Sent: Saturday, February 22, 2003 12:10 AM
Subject: Re: [SMARTY] nl2br in a template?
Post by Paul LockabyPost by Paul LockabyPost by gawanHi
I have text fields from a database to display through smarty template.
Is there a convenient way to use something similar to php nl2br()
to show new lines as <br> tags when in a template?
gawan
function smarty_modifier_nl2br($message) {
return nl2br($body);
}
Put that in a file by itself, named modifier.nl2br.php and then in your
{ $var|nl2br }
And poof(!) $var will have all newlines replaced with <BR>s. You can
http://smarty.incutio.com/?page=SmartyPlugins
For more ideas on plugins you can use to modify your text. I especially
like the bbcode2html plugin and use a modified version of it on my own site.
Hope that helps!
~Paul
Yeah, proofreading kicks ass, but only before you click "send". Lemme
rewrite those instructions so that they make sense. Put the above
function into a file called modifier.nl2br.php and save that file in
your plugins directory. Then call it as described from your template. I
hope that makes a *little* more sense.
--
Paul Lockaby
http://www.paullockaby.com
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php