[TYPO3-mvc] Fluid

Bastian Waidelich bastian at typo3.org
Wed Apr 22 12:48:22 CEST 2009


Peter Schuster wrote:

He Peter,

> In my opinion <f:format.currency currencySign="$" decimalSeparator="." 
> thousandsSeparator=",">321</f:format.currency> is much more intuitive, 

You pose a question that we asked ourselves in the last days:
when to use attributes and when to use child nodes as value for view 
helpers.
So
<f:xyz value="to be rendered">to be removed</f:xyz>
vs
<f:xyz>to be rendered</f:xyz>

In smarty there exists a similar approach:
{$toBeRendered|strip}
and
{textformat}to be rendered{/textformat}

(they are called modifiers and blocks there IIRC)

Now theres advantages and disadvantages for both ways.
For example if you use the tag contents, you can nest multiple view helpers:
<f:foo><f:bar>to be rendered</f:bar></f:foo>

using attributes you can put dummy contents in between the tags to be 
able to get a proper preview when opening the template in your browser:
<f:form.textbox value="{customer.name}"><input type="text" 
value="###dummy###" /></f:form.textbox>

or, to stick with your example:
<f:format.currency amount="{article.price}" currencySign="$" 
decimalSeparator="." thousandsSeparator=",">###article 
price###</f:format.currency>

But you're right, at least the format view helpers should be changed to 
use the tag contents. The disadvantage of the missing output when 
previewing the template will be gone as soon as we have the infamous 
"short-hand syntax". That is:

{f:format.currency(321.0)}

(see http://forge.typo3.org/wiki/package-fluid#Extended-short-hand-syntax)


Thanks for the feedback!
Bastian


More information about the TYPO3-project-typo3v4mvc mailing list