|
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 |
kaitlyn2004 Smarty Regular
Joined: 26 Apr 2007 Posts: 47
|
Posted: Wed Mar 17, 2010 5:51 pm Post subject: str_repeat problem? |
|
|
So before I would use:
Code: | {' '|str_repeat:4*$depth} |
but now with smarty 3, my output is just a "0" and I had to change to:
Code: | {str_repeat(' ',4*$depth)} |
No problem myself with this change, but is this perhaps a bug.. or what changed/what did I miss? |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Mar 17, 2010 6:45 pm Post subject: |
|
|
As Smarty 2 did handle mathematical expressions not in a general way parsing results may differ in Smarty3.
Smarty3 did parse it as
{(' '|str_repeat:4)*$depth}
correct syntax for this case would be
Code: | {' '|str_repeat:(4*$depth)} |
|
|
Back to top |
|
Aristophan Smarty Regular
Joined: 10 Jan 2011 Posts: 96
|
Posted: Sat Oct 06, 2012 6:50 pm Post subject: |
|
|
May I just hook this thread up into mind...
Is there something wrong using Code: | {' '|@str_repeat:$folder.depth*2} |
with Smarty3 ? With current 3.1.12 we get 0, where should be nothing. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sat Oct 06, 2012 8:54 pm Post subject: |
|
|
In Smarty3 resolving a modifer has higher priority as multiplication. So you have to use parenthesis to get the multiplication executed first.
Code: | {' '|str_repeat:($folder.depth*2)} |
|
|
Back to top |
|
Aristophan Smarty Regular
Joined: 10 Jan 2011 Posts: 96
|
Posted: Sun Oct 07, 2012 8:40 am Post subject: |
|
|
Thanks Uwe!
That was the first I tried... without luck, ...but as it returns, I did not change the right tpl's, while in a testcase. Issue solved! |
|
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
|