Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

{if $data==$data2|cat:'xx'} doesn't work in beta 6

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
geki007
Smarty n00b


Joined: 12 Jan 2010
Posts: 2

PostPosted: Tue Jan 12, 2010 2:45 pm    Post subject: {if $data==$data2|cat:'xx'} doesn't work in beta 6 Reply with quote

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
View user's profile Send private message
rincewind
Smarty Rookie


Joined: 13 Nov 2007
Posts: 5

PostPosted: Tue Jan 12, 2010 3:31 pm    Post subject: Reply with quote

Same error with:
Code:

{$dvd->Length/60|string_format:"%d"}

Works with beta5, but not with beta6.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Tue Jan 12, 2010 4:04 pm    Post subject: Reply with quote

bug, we'll get it fixed
Back to top
View user's profile Send private message Visit poster's website
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Tue Jan 12, 2010 8:05 pm    Post subject: Reply with quote

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
View user's profile Send private message
nielsNL
Smarty Rookie


Joined: 03 May 2009
Posts: 17

PostPosted: Tue Jan 12, 2010 10:40 pm    Post subject: Reply with quote

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
View user's profile Send private message
elpmis
Smarty Elite


Joined: 07 Jun 2007
Posts: 321

PostPosted: Wed Jan 13, 2010 7:54 am    Post subject: Reply with quote

nielsNL wrote:
i like this restriction, it makes it very clear where the modifier belongs to.


Second this ...
Back to top
View user's profile Send private message
geki007
Smarty n00b


Joined: 12 Jan 2010
Posts: 2

PostPosted: Wed Jan 13, 2010 8:13 am    Post subject: Reply with quote

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
View user's profile Send private message
Michael White
Smarty Rookie


Joined: 08 Oct 2009
Posts: 20

PostPosted: Thu Jan 14, 2010 5:49 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Aryos
Smarty Rookie


Joined: 12 Jan 2010
Posts: 8

PostPosted: Thu Jan 14, 2010 12:21 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3 All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP