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

what's the grammer currently in smarty3?

 
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
yarco
Smarty Regular


Joined: 20 Mar 2009
Posts: 39

PostPosted: Fri Mar 20, 2009 4:30 pm    Post subject: what's the grammer currently in smarty3? Reply with quote

The classic one:

Code:

{$sysinfo.totaltime|string_format:"%.3f"}


i've tried:
Code:

{$sysinfo['totaltime']->string_format("%.3f")}


seems doesn't work...so how to do that now?
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Fri Mar 20, 2009 4:40 pm    Post subject: Reply with quote

The original format should work if it was assigned the same?
Back to top
View user's profile Send private message Visit poster's website
yarco
Smarty Regular


Joined: 20 Mar 2009
Posts: 39

PostPosted: Fri Mar 20, 2009 4:51 pm    Post subject: Reply with quote

great, it could work!
what about the new style if want to add a modifier to this one?

{$abc['test']}

i think we would drop the old style in future.

Quote:

How to add modifiers in PHP templates:
Modifier are added like a method to the variables.
<?=$foo->escape('html')?>
Modifier can be chained.
<?=$foo->truncate(5)->escape('html')?>
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Fri Mar 20, 2009 5:01 pm    Post subject: Reply with quote

This should work too:

Code:
{$sysinfo['totaltime']|string_format:"%.3f"}


If you want to use php-style format, then use PHP templates instead Smile
Back to top
View user's profile Send private message Visit poster's website
yarco
Smarty Regular


Joined: 20 Mar 2009
Posts: 39

PostPosted: Fri Mar 20, 2009 5:04 pm    Post subject: Reply with quote

erm...though dot grammer is cute

<p>{{$sysinfo['queries']}} queries {{$sysinfo.totaltime|string_format:"%.3f"}}s</p>

but if i use two styles in one template. it would be very dirty.
So i support new style and drop the old one. That's ok. i think.
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Fri Mar 20, 2009 5:06 pm    Post subject: Reply with quote

Use whatever you wish. The dot syntax is meant to make things a little less syntax-ridden in the templates. But, use what you are comfortable with.
Back to top
View user's profile Send private message Visit poster's website
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