View previous topic :: View next topic |
Author |
Message |
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Nov 23, 2009 4:14 pm Post subject: Smarty 3 beta 5 released |
|
|
The fifth beta 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!
http://www.smarty.net/ |
|
Back to top |
|
httpete Smarty Rookie
Joined: 05 Dec 2009 Posts: 27
|
Posted: Sat Dec 05, 2009 1:58 am Post subject: Works great |
|
|
We have a large app with tons of investment in smarty 2. I just replaced it with Smarty 3 in about an hour. It is really peppy and the backwards compat work with smarty 2 is awesome. The only things I had to do were:
1.) Remove all calls to s_math ( a compiler plugin), change those to {math}
2.) some variables in the math calls needed an |intval in order to fly. Seems I was handing in a string before , and it needed an integer.
3.) The backtick syntax, which was ok in smarty 2 is no good. It was ugly anyway, and is much more straightforward with the {$var} in attributesl. so this:
{assign var="foo" value=`$whatver`-plainstring" }
is now
{assign var="foo" value="{whatever}-plainstring"} |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sat Dec 05, 2009 2:05 am Post subject: |
|
|
hmm backticks should work ok |
|
Back to top |
|
httpete Smarty Rookie
Joined: 05 Dec 2009 Posts: 27
|
Posted: Sat Dec 05, 2009 2:41 am Post subject: Found a potential bug |
|
|
This is not working on smarty 3:
so I have a {foreach name="cols_to_display" }
and
{$smarty.foreach.cols_to_display.total} used to work , echoing the count.. I see in the readme:
$var@total foreach $var array total
but shouldnt the old syntax still work? This will really be hard for me, we have hundreds of foreach loops. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sat Dec 05, 2009 2:46 am Post subject: |
|
|
yes it should work, we'll take a look |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sun Dec 06, 2009 1:16 pm Post subject: |
|
|
Backtick syntax is still working.
In your example you had a missing double quote:
{assign var="foo" value="`$whatver`-plainstring"}
{$smarty.foreach.cols_to_display.total} syntax does work.
All of the special Smarty variables $smarty.foreach... nad $smarty.section... are still available.
Also you could get rid of all {math} tags. In SMarty 3 you can do math in any place directly.
Examples:
{$foo+$bar} will output the sum of $ foo and $bar
{counter start=$foo+$bar}
etc. |
|
Back to top |
|
httpete Smarty Rookie
Joined: 05 Dec 2009 Posts: 27
|
Posted: Mon Dec 07, 2009 2:07 am Post subject: Not working for me |
|
|
So everything worked great, then I went to Smarty 3, and these errors got thrown and the only way I could fix was to remove the backticks on the include line below.
Code: |
{assign var="include_filename" value="`$plugin_dir`submit-`$smarty.get.tpl`.tpl"}
{include file=`$include_filename`}
|
gives error: Syntax Error in template "/home/smith/GenomeQuest/trunk/src/web/system_plugins/Workflows/GqWfChipseq/submit.tpl" on line 31 "{include file=`$include_filename`}" - Unexpected "`", expected one of: "{" , "identifier" , "$" , "closing tag" , INTEGER , "+" , "-" , "(" , TYPECAST , "boolean" , "null" , SINGLEQUOTESTRING , """ , "#" , "["
The smarty.foreach.foreachloopname.total variable is empty in mine. Used to work fine.
Oh another clue - the smarty.foreach.foreachloopname.total is inside ANOTHER included template would that matter?
Code: |
{foreach from=$columns_to_display item=cell name="cols_to_display"}
{include file="anotherfilethattriesToEchoDotTotal"}
{/foreach} | [/code] |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Dec 07, 2009 2:53 am Post subject: |
|
|
This isn't valid:
{include file=`$include_filename`}
Not even in Smarty 2. Needs to be:
{include file=$include_filename} |
|
Back to top |
|
jakweb Smarty n00b
Joined: 07 Dec 2009 Posts: 1
|
Posted: Mon Dec 07, 2009 9:38 am Post subject: |
|
|
Looking forward to try smarty 3, keep going guys... |
|
Back to top |
|
httpete Smarty Rookie
Joined: 05 Dec 2009 Posts: 27
|
Posted: Mon Dec 07, 2009 1:30 pm Post subject: |
|
|
so that used to work in smarty 2 with no error, but that is ok since it is easy to fix. Its the .total issue which is my biggest one now. It is clearly not echoing inside included files within the foreach loop. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Dec 07, 2009 3:47 pm Post subject: |
|
|
In Smarty 2 the special Smarty variables $smarty.section... and $smarty.foreach... had global scope. If you had loops with same name in subtemplates you could accidentally overwrite values of parent template.
In Smarty 3 these special Smarty variable have only local scope in the template which is defining the loop. If you need their value in a subtemplate you have to pass them as parameter.
Code: |
{include file='foo.tpl' total=$smarty.foreach.cols_to_display.total}
|
Recently the SVN was extended by a file SMARTY2_BC_NOTES. It does contain a description of all know backward incompatibilities. |
|
Back to top |
|
httpete Smarty Rookie
Joined: 05 Dec 2009 Posts: 27
|
Posted: Mon Dec 07, 2009 3:55 pm Post subject: |
|
|
OK, and this applies to the rest of them like next, first, and last? I can see the rationale behind this. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Dec 07, 2009 4:03 pm Post subject: |
|
|
Yes that applies for all special variables related to the foreach and section tag. |
|
Back to top |
|
httpete Smarty Rookie
Joined: 05 Dec 2009 Posts: 27
|
Posted: Thu Dec 10, 2009 7:22 pm Post subject: Warning thrown - line 51 of smarty_method_clear_compiled_tpl |
|
|
Saw this today
<br /> Warning: substr_compare() [<a href='function.substr-compare'>function.substr-compare</a>]: The length cannot exceed initial string length in /home/hwan/my/root/path/Smarty/sysplugins/smarty_method_clear_compiled_tpl.php on line 51<br /> |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Fri Dec 11, 2009 2:25 pm Post subject: |
|
|
This is fixed in the SVN now |
|
Back to top |
|
|