Re: [SMARTY] nl2br in a template?

From: Date: Wed, 26 Feb 2003 22:00:15 +0000
Subject: Re: [SMARTY] nl2br in a template?
References: 1 2 3 4  Groups: php.smarty.dev php.smarty.general 
Request: Send a blank email to php-smarty-dev+get-848@lists.php.net to get a copy of this message
> This can be added, sounds useful enough. A few questions: > > 1) Is there a better name, or keep nl2br for consistancy of PHP > developers familiarity? nl2br is nice and short though... Keep it. > 2) Should it always return XHTML compliant code <br />, regardless of > PHP version? the PHP command nl2br() pre-PHP 4.0.5 doesn't output XHTML > break tags. I think it would be good to always be XHTML compliant. So you're going to re-implement the function and not use the default nl2br()? If so, then yeah, always make it output XHTML compliant tags. > 3) Should it cover newline formats from Mac/PC appropriately? In > otherwords replace \n or \r\n with <br /> tags? The regular nl2br() does this already, so yeah, it should. > 4) Should it replace newlines already preceeded by a <br> tag? > Controllable option? If so, what should be default? Yes, replace any newlines. If your text already has HTML code in it, then you probably shouldn't be calling nl2br() on it anyhow. Overall, just a wrapper to the regular nl2br() function would be the best, I think. Why recreate it? Wouldn't it just be smarter overall to convince people to use the $smarty->register() method? (which I just learned about) Otherwise it seems like you'd just end up writing a smarty.modifier file for every PHP function that people want. ---John Holmes...

« previous php.smarty.dev (#848) next »