|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
yarco Smarty Regular
Joined: 20 Mar 2009 Posts: 39
|
Posted: Fri Mar 20, 2009 4:30 pm Post subject: what's the grammer currently in smarty3? |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Mar 20, 2009 4:40 pm Post subject: |
|
|
The original format should work if it was assigned the same? |
|
Back to top |
|
yarco Smarty Regular
Joined: 20 Mar 2009 Posts: 39
|
Posted: Fri Mar 20, 2009 4:51 pm Post subject: |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Mar 20, 2009 5:01 pm Post subject: |
|
|
This should work too:
Code: | {$sysinfo['totaltime']|string_format:"%.3f"} |
If you want to use php-style format, then use PHP templates instead |
|
Back to top |
|
yarco Smarty Regular
Joined: 20 Mar 2009 Posts: 39
|
Posted: Fri Mar 20, 2009 5:04 pm Post subject: |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Mar 20, 2009 5:06 pm Post subject: |
|
|
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 |
|
|
|
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
|