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

Bug in {assign}?

 
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
tgenannt
Smarty Rookie


Joined: 05 Dec 2009
Posts: 5

PostPosted: Sat Dec 05, 2009 2:18 pm    Post subject: Bug in {assign}? Reply with quote

Hello,

I'am using the {assign} tag like this:
Code:
{assign var="trStyles" index=0 value='style="background-color:#FFFFFF;"'}
{assign var="trStyles" index=1 value='style="background-color:#EFEFEF;"'}


This produces the following compiled output:

Code:
$_tmp0 = 'style="background-color:#FFFFFF;"'; $_smarty_tpl->append("trStyles",$_tmp,true,null,null); unset ($_tmp);
$_tmp1 = 'style="background-color:#EFEFEF;"'; $_smarty_tpl->append("trStyles",$_tmp,true,null,null); unset ($_tmp);


There seems to be a mismatch between the names of the temporary variable.

A fix for this problem is to replace the line
Code:
return "<?php \$_tmp$_attr[index] = $_attr[value]; \$_smarty_tpl->append($_attr[var],\$_tmp,true,$_nocache,$_scope); unset (\$_tmp);?>";
with this line
Code:
return "<?php \$_tmp$_attr[index] = $_attr[value]; \$_smarty_tpl->append($_attr[var],\$_tmp$_attr[index],true,$_nocache,$_scope); unset (\$_tmp$_attr[index]);?>";
in the class Smarty_Internal_Compile_Assign.

Greetings,
Tobias
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Sat Dec 05, 2009 3:35 pm    Post subject: Reply with quote

Where did you got this
Code:
{assign var="trStyles" index=0 value='style="background-color:#FFFFFF;"'}

syntax from?

It was never intended that index is an attribute of the assign tag.

It was used internally for mapping the new assign syntax

Code:
{$trStyles[0]='style="background-color:#FFFFFF;"'}


to the assign compiler code.

I think I must close this hole....
Back to top
View user's profile Send private message
tgenannt
Smarty Rookie


Joined: 05 Dec 2009
Posts: 5

PostPosted: Sat Dec 05, 2009 3:42 pm    Post subject: Reply with quote

I found the "index" attribute in the code of the mentioned class and thought I could just use it.

I will convert my template to use the new assign syntax.
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