|
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 |
Hpatoio Smarty Rookie
Joined: 29 Apr 2003 Posts: 25 Location: Italy
|
Posted: Wed Apr 30, 2003 8:32 pm Post subject: Conbine "truncate" and "strip_tags" modi |
|
|
This is not really a bug ... but I really didn't know where to post it !
So, suppose U have a field with some HTMl inside !
And suppose that U use it like this
Code: |
<table>
<tr>
<td>
{$html_var|truncate:300|strip_tags}
</td>
</tr>
</table>
|
this can cause an error
because if at the char 290 (for example) the variable $html_var contains something like "<table><tr><td> text text text " the strip_tags modifier will not take away the <td> tag (because it doesn't find any end tag in the $html_var) !!!
So the code of your HTML will result corrupted !!!
U can resolve usign the 2 modifier in the differe order
Code: |
$html_var|strip_tags|truncate:300
|
But suppose that my var $html_var if very long and I have to display a list of these $html_var ... this will results in a real more CPU load ... or ?
I hope to have been clear enough ...
Simone |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Thu May 01, 2003 4:01 am Post subject: |
|
|
Very nice description of issue!
- The extra time could be mitigated using caching.
- if your your html are from static sources, you can store the stipped versions of them
- if this is the only need for $html_var, you can do the srip/truncate in PHP
- you can write a new strip_tags plugin that supports an optional truncate field. |
|
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
|