Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Smarty 3 RC2 released

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
mohrt
Administrator


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

PostPosted: Mon Jun 14, 2010 5:44 pm    Post subject: Smarty 3 RC2 released Reply with quote

The second RC of Smarty 3 has been released! Please join the developer mailing list and see the Smarty 3 section of the forums and give us feedback!

NOTE: Documentation for Smarty 3 is still being finalized, please use the README for now.

http://www.smarty.net/
Back to top
View user's profile Send private message Visit poster's website
Mastershrimp
Smarty Regular


Joined: 21 Dec 2009
Posts: 53

PostPosted: Mon Jun 14, 2010 8:43 pm    Post subject: Reply with quote

Thanks! Great job!

I just updated yesterday on RC1.... Razz
Well, I encountered some problems with an own template function of mine. In PHP5.3 there is a warning about the $smarty parameter being "expected to be a reference, value given". I correctly wrote "&$smarty" in the function's definition and PHP5.2.x worked fine.

After googleing and searching the forum I solved the problem by simply removing the "&"...but is that really a good solution?

Maybe you should investigate that problem since it seems that several other users in this problem are facing this problem as well.

Note: I used the RC1 and didnt check whether it still occurs in RC2. But since the changelog didt say anyting like that I think it's still an issue.


Still, great Job! Looking forward to the final!
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Mon Jun 14, 2010 8:48 pm    Post subject: Reply with quote

Normally this is a difference between PHP4 and PHP5, as it handles references differently. When you upgrade to PHP5 you may remove & in lots of places in your scripts. Are you sure this isn't a difference in PHP behavior and not Smarty?

ed: you might also see this if you pass a scalar value such as null or a "string" as a property expecting a reference to a variable. so if you have:

function foobar($foo,&$bar) { ... }

and you call it as:

foobar($foo,null);

error! then remove the & and it works.
Back to top
View user's profile Send private message Visit poster's website
vorapoap
Smarty Rookie


Joined: 22 Dec 2009
Posts: 32

PostPosted: Wed Jun 16, 2010 1:42 pm    Post subject: Template Function Scope Reply with quote

Oh.. sorry.. my problem solved after clearing all the cache...

Thank you for this great library.

[removed]

Any one if have a problem after replacing Smarty with the new version, you may like to try clearing template caches first.
Back to top
View user's profile Send private message
vorapoap
Smarty Rookie


Joined: 22 Dec 2009
Posts: 32

PostPosted: Wed Jun 16, 2010 4:29 pm    Post subject: Reply with quote

OK this is really a bug.

I register a compiler function via $smarty->register->compilerFunction("t", "_compiler_t");

In template
Code:

{t t="xxxxx"}


In php
Code:

function _compiler_t($args, $smarty) {
      return "\n<?php echo _('". str_replace("'", "\\'", $args['t'])."'); ?>";
}


Firstly, $args['t'] always contains starting and tailing quotes, no matter it is double (") or single(')

Secondly, in Smarty2, I don't think we need to return <?php .. ?> ? Probably this is now changed in Smarty3
Back to top
View user's profile Send private message
VEG
Smarty Rookie


Joined: 02 May 2010
Posts: 20
Location: Belarus

PostPosted: Tue Jul 06, 2010 7:58 am    Post subject: Reply with quote

In Smarty 2 $smarty.template contains relative path to template and filename. In Smarty 3 this variable contains only filename. Is it correct behaviour?
Back to top
View user's profile Send private message
VEG
Smarty Rookie


Joined: 02 May 2010
Posts: 20
Location: Belarus

PostPosted: Tue Jul 06, 2010 8:07 am    Post subject: Reply with quote

And maybe you add deprecation notice for foreach with with identical from and item attributes.
Code:
{foreach item=blah from=$blah}
{$blah}
{/foreach}
This code correctly works in Smarty 2 and don't works in Smarty 3 at all.
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Tue Jul 06, 2010 12:52 pm    Post subject: Reply with quote

VEG wrote:
And maybe you add deprecation notice for foreach with with identical from and item attributes.
Code:
{foreach item=blah from=$blah}
{$blah}
{/foreach}
This code correctly works in Smarty 2 and don't works in Smarty 3 at all.


It really shouldn't work. Why would you give the loop the same name as the looped variable? That is like doing this in PHP:

foreach($foo as $foo)
Back to top
View user's profile Send private message Visit poster's website
VEG
Smarty Rookie


Joined: 02 May 2010
Posts: 20
Location: Belarus

PostPosted: Tue Jul 06, 2010 1:04 pm    Post subject: Reply with quote

This code works perfectly and outputs "123" in PHP 5
Code:
<?php
$a = array(1,2,3);
foreach($a as $a)
{
   echo($a);
}
?>

I know that is very bad style, but many old codes uses this bug (or feature =) ). Maybe you add error output or deprecation notice for this case?
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Tue Jul 06, 2010 1:08 pm    Post subject: Reply with quote

hmm. I guess I didn't realize PHP would actually support it. If it's easy enough we might allow it in the parser, but not make note that it's an option.
Back to top
View user's profile Send private message Visit poster's website
U.Tews
Administrator


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

PostPosted: Tue Jul 06, 2010 7:08 pm    Post subject: Reply with quote

{foreach item=blah from=$blah} did loop correctly in Smarty2 but did create also problems if you wanted to use the original value of array $blah later on, as the loop did overwrite the original value.

There is a patch in the SVN now which throws an exception in this condition.
Back to top
View user's profile Send private message
VEG
Smarty Rookie


Joined: 02 May 2010
Posts: 20
Location: Belarus

PostPosted: Tue Jul 06, 2010 10:10 pm    Post subject: Reply with quote

U.Tews, Thank you.
What about
VEG wrote:
In Smarty 2 $smarty.template contains relative path to template and filename. In Smarty 3 this variable contains only filename. Is it correct behaviour?
Back to top
View user's profile Send private message
Mastershrimp
Smarty Regular


Joined: 21 Dec 2009
Posts: 53

PostPosted: Thu Jul 15, 2010 6:20 am    Post subject: Reply with quote

mohrt wrote:
Normally this is a difference between PHP4 and PHP5, as it handles references differently. When you upgrade to PHP5 you may remove & in lots of places in your scripts. Are you sure this isn't a difference in PHP behavior and not Smarty?


Sorry for my late response, I didnt check this thread for quite some time...
To your question: I dont know actually. I'm using PHP5 since years, and just recently updated Smarty - so I guessed it's Smarty's fault....?
Well, and it seems to be PHP5.3-specific...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    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