Bug #41008

f:format.currency should use trim

Added by Cedric Ziel almost 3 years ago. Updated over 1 year ago.

Status:Rejected Start date:2012-09-17
Priority:Should have Due date:
Assigned To:- % Done:

0%

Category:ViewHelpers
Target version:-
Has patch:No Affected Flow version:(any)

Description

Hello; if you use an IDE and use their reformat feature, you have the problem that viewhelpers get splitted up into several lines just like in the example:

<f:format.currency currencySign="€" decimalSeparator="," thousandsSeparator=".">
   {object.amount}
</f:format.currency>

This results in non-supported chars for format_number.

The Viewhelper therefore should trim before calling number_format:

number_format(trim($stringToFormat), 2, $decimalSeparator, $thousandsSeparator);

History

#1 Updated by Adrian Föder almost 3 years ago

  • Status changed from New to On Hold

voted down because: if the value must not have whitespaces, it... must not have whitespaces.

Especially your IDE is misconfigured then, because it would also break inline html elements, for example.
To workaround, either use the inline variant or check whether to fix the IDE.
Generally, I personally discourage XML autoformatting because it mostly results worse than intended (especially since whitespaes in HTML have special impacts; other than in XML)

//edit: some additional word; of course we could just add a trim() here; but this would be a special treatment there compared to the other ViewHelpers and therefore add inconsistencies.
I tend to keep the ViewHelpers, regarding to their HTML behavior, mostly "as-is"; meaning: if you surround something with whitespaces, the whitespaces will stay there without "magic" disappearance.

If you want to split the very long line into more, you could do

1<f:format.currency
2  currencySign="" 
3  decimalSeparator="," 
4  thousandsSeparator=".">{object.amount}</f:format.currency>

#2 Updated by Cedric Ziel almost 3 years ago

For inline Notation, this is true, but this behavior is simply not expected in explicit Markup.

HTML ignores such Chars in most cases, FLUID uses HTML Notation. Failing for those errors is very annoying and could easily be suppressed by adding standard-trim.

#3 Updated by Sebastian Kurfuerst almost 3 years ago

  • Status changed from On Hold to Rejected

I agree with Adrian's comments; I'd use the inline notation in this case:

{object.amount -> f:format.currency(currencySign:'€', decimalSeparator: ',', thousandsSeparator: '.')}

Adding some "trim" behavior would be very inconsistent with the way Fluid works now and is expected to work. We leave whitespaces completely untouched.

Greets, Sebastian

#4 Updated by Cedric Ziel almost 3 years ago

I'm okay with that :-)
were just my two cents.

Thanks for clarification. Maybe the docs should point that out more clearly? I think this issue is mostly about formatters which would break if someone insists on using them explicitly.

Cedric

Also available in: Atom PDF