|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
joo Smarty Rookie
Joined: 24 Oct 2003 Posts: 11 Location: Moscow, Russia
|
Posted: Tue Jun 01, 2004 1:02 pm Post subject: strip_tag modifier replaces with ' ', not '' |
|
|
strip_tag modifier works incorrectly.
Documentation:
Code: | Example 5-20. strip_tags
index.php:
$smarty = new Smarty;
$smarty->assign('articleTitle', "Blind Woman Gets <font face=\"helvetica\">New Kidney</font> from Dad she Hasn't Seen in <b>years</b>.");
$smarty->display('index.tpl');
index.tpl:
{$articleTitle}
{$articleTitle|strip_tags}
OUTPUT:
Blind Woman Gets <font face="helvetica">New Kidney</font> from Dad she Hasn't Seen in <b>years</b>.
Blind Woman Gets New Kidney from Dad she Hasn't Seen in years. |
function smarty_modifier_strip_tags() in Smarty code:
Code: | function smarty_modifier_strip_tags($string, $replace_with_space = true)
{
if ($replace_with_space)
return preg_replace('!<[^>]*?>!', ' ', $string);
else
return strip_tags($string);
} |
It produces redundant space (" ") instead null-string ("").
It's not a big bug, but it's no good... |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue Jun 01, 2004 1:13 pm Post subject: |
|
|
the documentation is missing the optional "replace_with_space"-parameter which defaults to true.
{$articleTitle|strip_tags:false} replaces tags with '', not with ' '. |
|
Back to top |
|
joo Smarty Rookie
Joined: 24 Oct 2003 Posts: 11 Location: Moscow, Russia
|
Posted: Tue Jun 01, 2004 1:18 pm Post subject: oops |
|
|
Thank you! |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue Jun 01, 2004 1:21 pm Post subject: |
|
|
I will update the docs |
|
Back to top |
|
|
|
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
|