View previous topic :: View next topic |
Author |
Message |
geki007 Smarty n00b
Joined: 12 Jan 2010 Posts: 2
|
Posted: Tue Jan 12, 2010 2:45 pm Post subject: {if $data==$data2|cat:'xx'} doesn't work in beta 6 |
|
|
Why doesn't
{if $data==$data2|cat:'xx'}
work in smarty 3 beta 6 and works in beta 5?
Error Message:
- Unexpected "|", expected one of: "}" |
|
Back to top |
|
rincewind Smarty Rookie
Joined: 13 Nov 2007 Posts: 5
|
Posted: Tue Jan 12, 2010 3:31 pm Post subject: |
|
|
Same error with:
Code: |
{$dvd->Length/60|string_format:"%d"}
|
Works with beta5, but not with beta6. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Jan 12, 2010 4:04 pm Post subject: |
|
|
bug, we'll get it fixed |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Jan 12, 2010 8:05 pm Post subject: |
|
|
Sorry
I did screw up the parser just before the release of beta 6.
The SVN is now updated with a version which does work with same
restriction as the SVN versions before.
The restrictions is:
If modifiers are used in {if...} or mathematical expressions you must
use parentheses like
{if ($products|@count) == 2}
{if ($newsitem.news_date|date_format:"%Y") == 2008}
{$x = ($y|strlen) + ($z|strlen)}
I will try to remove this restriction ASAP.
Uwe |
|
Back to top |
|
nielsNL Smarty Rookie
Joined: 03 May 2009 Posts: 17
|
Posted: Tue Jan 12, 2010 10:40 pm Post subject: |
|
|
i like this restriction, it makes it very clear where the modifier belongs to.
When it is not to much work can you make it optional or so? |
|
Back to top |
|
elpmis Smarty Elite
Joined: 07 Jun 2007 Posts: 321
|
Posted: Wed Jan 13, 2010 7:54 am Post subject: |
|
|
nielsNL wrote: | i like this restriction, it makes it very clear where the modifier belongs to. |
Second this ... |
|
Back to top |
|
geki007 Smarty n00b
Joined: 12 Jan 2010 Posts: 2
|
Posted: Wed Jan 13, 2010 8:13 am Post subject: |
|
|
nielsNL wrote: | i like this restriction, it makes it very clear where the modifier belongs to. |
generally i second this too
but for old projects it's very bad and i would prefer this:
nielsNL wrote: | When it is not to much work can you make it optional or so? |
|
|
Back to top |
|
Michael White Smarty Rookie
Joined: 08 Oct 2009 Posts: 20
|
Posted: Thu Jan 14, 2010 5:49 am Post subject: |
|
|
I would say that the parenthetical syntax would be nice to support, but should not be required since one goal is backwards compatibility with Smarty 2 templates. |
|
Back to top |
|
Aryos Smarty Rookie
Joined: 12 Jan 2010 Posts: 8
|
Posted: Thu Jan 14, 2010 12:21 pm Post subject: |
|
|
Having used in the past lots of Smarty modifiers, math functions and "assign" functions in templates, the only advice I can give, for performance, it to handle and format all possible data straight from the SQL query using "CASE", "CONCAT", "/", "%" etc modifiers) and avoid using such formatting in the PHP code or in the Smarty code.
Also avoid using functions in each record fetched, within Smarty which will result in an additional SQL query per row fetched. It saves a lot of memory and execution time, if you prepare the data for correct output right out of the SQL query. |
|
Back to top |
|
|