#72: number_format plugin
Issue attachments
Issue revisions
- new by m.krasilnikov at 2010-M-23 15:13
- new by m.krasilnikov at 2010-M-23 15:13
- closed by Jordi Boggiano at 2011-F-15 0:09
| Type | |
|---|---|
| State | |
| Priority | |
| Resolution | |
| Assigned to | Nobody |
| Scheduled for | |
| Affected versions | |
| Affected components | Plugins |
| Last change | Tuesday 15 February 2011 00:09:34 UTC by Jordi Boggiano |
I want to offer a simple plugin that implements a number_format functionality in Dwoo templates.
Jordi Boggiano at Sunday 23 May 2010 15:34:14 UTC
Mhh.. I fail to understand the use of this, considering you can directly call php's number_format function from templates. If you restricted function calls via a Dwoo_Security_Policy, you should just allow number_format to be called.
m.krasilnikov at Monday 24 May 2010 07:06:49 UTC
How can I call PHP's functions directly? I can not find this in the documentation (http://wiki.dwoo.org/).
And why then need plguin string_format?
http://wiki.dwoo.org/index.php/Functions:string_format
http://svn.dwoo.org/trunk/lib/plugins/builtin/functions/string_format.php
m.krasilnikov at Monday 24 May 2010 07:30:05 UTC
By the way. I know one reason why this should be implemented in template engine. Why template engine needed at all? All its functionality can be implemented in PHP+HTML. But this can be done only by PHP developer and not by man who knows only HTML/CSS. And the main purpose of template engine is to give this man abilities to create templates without learning PHP. Number formatting is a very common task. And it's not documented Dwoo docs. How can a non-PHP-developer guess that he can use PHP functions?
Sorry for my English, it's not my native language.
Jordi Boggiano at Monday 24 May 2010 10:10:38 UTC
string_format imo isn't needed, but I added it to remain compatible with Smarty. Also, I may see some kind of use in the fact that it provides a name that is easier to grasp than sprintf for designers..
That being said, I don't really oppose adding number_format, but I'm just afraid that if we add that then we can add half of the php function, so maybe a more sensible solution would be to document the useful php functions for designers that can be used in dwoo in the dwoo wiki?
m.krasilnikov at Monday 24 May 2010 15:16:28 UTC
That is only my own view.
I understand that this question not for bug tracker but anyway, where I can find how to call PHP functions from templates?
Jordi Boggiano at Monday 24 May 2010 15:29:10 UTC
Well, you just call them as if it was normal Dwoo plugins, nothing is needed.. your example would be: {number_format $number 3 "."} or {number_format($number, 3, ".")}
The only advantage to building a Dwoo plugin is that you can then call it using named parameters like: {number_format number=$number decimals=3}
I must say I almost never use that syntax so I didn't think of it as an advantage, but that might make worth it to add it to Dwoo. However adding it means adding it to the documentation pages etc.. And I honestly don't have much time for such things lately. So if you would like to help and provide a few useful plugins that just wrap php functions and do the documentation work, you're very welcome. The wiki is open to all.
m.krasilnikov at Tuesday 25 May 2010 09:56:08 UTC
OK. I already made some changes to the Dwoo wiki, mostly translations to Russian.