Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Smarty 3 beta 5 released
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
httpete
Smarty Rookie


Joined: 05 Dec 2009
Posts: 27

PostPosted: Fri Dec 11, 2009 3:48 pm    Post subject: It is really beautiful Reply with quote

Smarty team,

I must say that this upgrade has been one of the nicest, and smoothest of a major library I have ever used. Just to share my findings with others:

1.) The variable / scoping improvements (specifically that global variables are not available in included sub templates) seems like a pain, but really enforces stronger and clearer templates. I had to take the hit to pass some global variables that we relied on through each include like {include file="foo" mycustomvar=$whatever}. Soe the end product is a stricter and better scoped template.

2.) The smarty parser is a bit stricter when it comes to whitespace within tags. Many templates broke due to extra spaces before the end }. Removing those fixed it right away. If you want to eliminate your "{literal}" mess, be aware that you WILL need the space before and after the { say in a css declaration. So, .class { whatever: wha }. All in all, it looks cleaner and is more consistent.

3.) Getting rid of the few places I hacked {php} tags was a breeze. {php}echo ini_get('var'){/php} simply becomes {ini_get('var')}. Boom. Clean, easier.

The best part of this new smarty is that it tightens up the few areas of smarty where it was too loosey goosey, but still allows the famous flexibility that smarty is known for. I am really enjoying scraping out all of the literal tags and cleaning up our syntax. It is faster, and my templates are cleaner, and it straightens our butts out a bit too. Thanks smarty folks.

</httpete>
Back to top
View user's profile Send private message
gwuertz
Smarty n00b


Joined: 12 Dec 2009
Posts: 1

PostPosted: Sat Dec 12, 2009 10:50 pm    Post subject: Reply with quote

One place where loosey goosey is really missed is in the config files. For example this setting:
Code:

trace=


throws a syntax error exception. Ditto for settings whose values contain '='. The exception is problematic, since a minor config change can now kill the application - very different from smarty 2 where the only split milk would be the offending change.
Back to top
View user's profile Send private message
Thue
Smarty Rookie


Joined: 06 Jul 2006
Posts: 5

PostPosted: Sat Dec 19, 2009 1:18 am    Post subject: Reply with quote

I get an error in config files containing a line "#", without any other characters before or after #.
Back to top
View user's profile Send private message
Thue
Smarty Rookie


Joined: 06 Jul 2006
Posts: 5

PostPosted: Sat Dec 19, 2009 1:42 am    Post subject: Reply with quote

You probably want something like the following:


Index: development/lexer/smarty_internal_configfileparser.y
===================================================================
--- development/lexer/smarty_internal_configfileparser.y (revision 3404)
+++ development/lexer/smarty_internal_configfileparser.y (working copy)
@@ -109,6 +109,7 @@
}} res ='';}
// empty and comment lines
config_element(res) ::= EOL. { res ='';}
+config_element(res) ::= COMMENTSTART opteol. { res ='';}
config_element(res) ::= COMMENTSTART text(t) opteol. { res ='';}

value(res) ::= text(t). {res = t;}
Index: development/PHPunit/configs/test.conf
===================================================================
--- development/PHPunit/configs/test.conf (revision 3404)
+++ development/PHPunit/configs/test.conf (working copy)
@@ -24,3 +24,14 @@
[.hidden]
hiddentext = Hidden Section

+#Comment
+# Comment with a space first line first
+ #Comment line starting with space
+ # Space before and after #
+#The line below only contains a #
+#
+#
+# title = This is not the correct title
+
+#[section1]
+#sec1 = Wrong text
\ No newline at end of file
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Sat Dec 19, 2009 12:38 pm    Post subject: Reply with quote

A fix for the comment lines is in the SVN now
Back to top
View user's profile Send private message
patlecat
Smarty n00b


Joined: 22 Dec 2009
Posts: 1

PostPosted: Tue Dec 22, 2009 1:28 pm    Post subject: Roadmap?? Reply with quote

Is there a Roadmap for V3? I mean when do you project Smarty3 to be feature complete and to go into an RC or release? I'd love to use it for my next project.
Back to top
View user's profile Send private message
nulled
Smarty Rookie


Joined: 30 Jun 2006
Posts: 5
Location: washington

PostPosted: Sun Dec 27, 2009 6:52 pm    Post subject: Template Lite and Dwoo Reply with quote

Two Smarty compatible engines have emerged which claim to be faster and less memory consumption than Smarty. Template Lite and Dwoo.

Is this a problem to be concerned? Is there a way to use unset() for manual GC or other ways to make a smaller memory footprint? Or does it not really matter, but only to the super geeky speed freaks among us?

Thanks,
Smarty 4 Life Smile
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
mohrt
Administrator


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

PostPosted: Sun Dec 27, 2009 11:31 pm    Post subject: Reply with quote

Both of these engines are compared to Smarty 2, not Smarty 3. Smarty 3 is a completely different code base with many new features, so we'll see how things compare after the dust settles. In any event, there is no one perfect tool for every job. You should use the tools that best suit your project.
Back to top
View user's profile Send private message Visit poster's website
httpete
Smarty Rookie


Joined: 05 Dec 2009
Posts: 27

PostPosted: Tue Dec 29, 2009 2:55 pm    Post subject: Latest SVN checkout has error Reply with quote

Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/smith/GenomeQuest/trunk/src/web/external_lib/Smarty/sysplugins/smarty_internal_template.php on line 765

Warning: Invalid argument supplied for foreach() in /home/smith/GenomeQuest/trunk/src/web/external_lib/Smarty/sysplugins/smarty_internal_template.php on line 768
Back to top
View user's profile Send private message
toycat
Smarty Rookie


Joined: 29 Dec 2009
Posts: 8

PostPosted: Tue Dec 29, 2009 10:16 pm    Post subject: error in resource caching ? Reply with quote

Hello.

When using user defined 'project' resource with cache enabled (i.e. $smarty->caching = 1), I got:

Code:
Warning: rename(D:\Apache2\htdocs\test\smarty-cache\cache\wrtD0C2.tmp,D:/Apache2/htdocs/test/smarty-cache/cache/223ff74af8193ae5ce69cff0ec4fcc401ef55d64.project:index.tpl.php) [function.rename]: Invalid argument in D:\Apache2\htdocs\_externals\Smarty3Dev\distribution\libs\sysplugins\smarty_internal_write_file.php on line 41


...followed by related mesages about non-existing file.

See the ...d64.project:index.tpl.php where the 'project:index.tpl' seems to be handled badly and the ':' character causes the warning and subsequent messages.

When disabling the cache (i.e. $smarty->caching = 0) it works fine.

Any change fixing this ASAP?

Thank you.
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Tue Dec 29, 2009 11:47 pm    Post subject: Reply with quote

A fix for the cache filename is in the SVN now.
Back to top
View user's profile Send private message
toycat
Smarty Rookie


Joined: 29 Dec 2009
Posts: 8

PostPosted: Wed Dec 30, 2009 9:47 am    Post subject: thank you Reply with quote

U.Tews wrote:
A fix for the cache filename is in the SVN now.


thank you! works like charm now.
Back to top
View user's profile Send private message
httpete
Smarty Rookie


Joined: 05 Dec 2009
Posts: 27

PostPosted: Wed Jan 06, 2010 9:41 pm    Post subject: Re: Latest SVN checkout has error Reply with quote

httpete wrote:
Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/smith/GenomeQuest/trunk/src/web/external_lib/Smarty/sysplugins/smarty_internal_template.php on line 765

Warning: Invalid argument supplied for foreach() in /home/smith/GenomeQuest/trunk/src/web/external_lib/Smarty/sysplugins/smarty_internal_template.php on line 768


Any word on this one guys? I upgraded to the latest from SVN and my whole site died. Worked fine with the beta 5 release.....
Back to top
View user's profile Send private message
toycat
Smarty Rookie


Joined: 29 Dec 2009
Posts: 8

PostPosted: Wed Jan 06, 2010 10:02 pm    Post subject: usability suggestion: object to array auto-cast Reply with quote

Hello.

This is just a suggestion, but I think it would be good, if one can enable automatic casting of objects to arrays when accessing variables inside Smarty template.

The reason for this is, that I use many variable structures, which are arrays of objects and the objects have again arrays of objects, etc. So the structure is something like this (arr)var1->(obj)var2->(arr)var3->(obj)var4... .

In Smarty I can now access $var2 by {$var1.var2} , but I cannot simply access {$var1.var2.var3}, because Smarty produces error (non-array access). It would be very nice, if I did not need to always convert the structures above using recursive (array)$var cast before giving them to Smarty, but if Smarty would done this for me.

I suggest, that when accessing inside Smarty template the array-like way (i.e. $var1.var2.var3), the Smarty should test each $var and if $var is object, Smarty should internally auto-cast it to array using (array)$var, so that the array-like access would be possible. The same should apply for Smarty {foreach} structure, where it should cycle through all object's public properties, which are not functions (methods).

I am pretty sure that it should be very minor change to Smarty engine, but the usability would greatly improve.

What do you think about this?
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Thu Jan 07, 2010 8:17 pm    Post subject: Reply with quote

I don't see where the problem is. In Smarty3 you can use something like

$var['var2']->var3['var4']->var5...

or

$var.var2->var3.var4->var5...

So there should be no need for any typecasting.

{foreach} does already iterate over the properties of an object.
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
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
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