Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

angular.formatter: usage examples could be clearer #998

Closed
radicaled opened this issue May 2, 2014 · 4 comments
Closed

angular.formatter: usage examples could be clearer #998

radicaled opened this issue May 2, 2014 · 4 comments

Comments

@radicaled
Copy link
Contributor

The usage example for the Date formatter looks like this:

{{ date_expression | date[:format] }}

I ended up trying the following variations before I had a hunch and tried the AngularJS way of doing it:

date[medium]
date[:medium]
date['medium']
date('medium')
date(:medium)
date(medium)

To contrast, here's how AngularJS shows a usage example:

{{ date_expression | date : format}}

This is much more obvious in my opinion, leaving little room for interpretation.

@technohippy
Copy link
Contributor

[..] is the standard way to show omittable options in the man command so that date[:format] means [:format] can be omitted. I prefer AngularDart style example because AngularJS style example does not tell :format is omittable.

@radicaled
Copy link
Contributor Author

How many people are going to recognize the relation between shell syntax
and optional parameters for formatters in AngularDart, though? It seems
like an archaic prerequisite to me.

@chalin
Copy link
Contributor

chalin commented May 4, 2014

IMHO, what is confusing to most is the use of : to separate the formatter name from its argument. If @vicb's #772 goes through, then the : will be replaced by standard parentheses and then the bracket notation will match with Dart's optional positional argument syntax. In fact, we could then improve the documentation by writing:

{{ date_expression | date([String format="mediumDate"]) }}

@vicb
Copy link
Contributor

vicb commented May 22, 2014

Most formatters now have example

 * # Example
 *
 *     {{ 1234 | currency }}                 // output is $1,234.00
 *     {{ 1234 | currency:'CAD' }}           // output is CAD1,234.00
 *     {{ 1234 | currency:'CAD':false }}    // output is  1,234.00CAD

@vicb vicb closed this as completed May 22, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

4 participants