Bug #5150

Rewrite ViewHelpers to support new inline notation

Added by Bastian Waidelich almost 6 years ago. Updated almost 5 years ago.

Status:Resolved Start date:2009-10-27
Priority:Should have Due date:
Assigned To:Bastian Waidelich % Done:

0%

Category:Core
Target version:-
Has patch: Affected Flow version:

Description

With the new syntax for the Fluid inline notation (aka "shorthand syntax") implemented with r3333 we introduced a breaking change:
While

{f:format.crop('{blog.title}' maxChars=30)}

can be transformed to the new syntax like:

{blog.title -> f:format.crop(maxChars: 30)}

... there currently is no equivalent for:

{f:format.crop('static string' maxChars=30)}

because we do not allow the syntax to be applied to static strings.
Obviously you can work around this by using the good old tag syntax, but IMO we should just allow:

{'static string' -> f:format.crop(maxChars: 30)}

The alternative (as discussed with Karsten) would be to rework all affected view helpers so that you could specify the value like this:

{f:format.crop(value: 'static string', maxChars: 30)}

Anyways, after thinking about this again, I'm in favor of supporting the above.
There are some exceptions though:
e.g.

{'css/styles.css' -> f:uri.resource()}

looks pretty odd and I'd change it to
{f:uri.resource(path: 'css/styles.css')}

Affected view helpers:
  • format.padding
  • format.number
  • format.currency
  • format.crop
  • format.date
  • format.nl2br
  • format.printf
  • cObject (v4 only)
  • translate (v4 only)
  • html (v4 only)
Affected view helpers that IMO don't need support for inline notation:
  • alias
  • for / groupedFor
  • cycle
  • if / then / else
  • security.ifGrantedAuthority / security.ifAccess (v5 only)
  • be.container (v4 only)
  • debug (v4 only)
  • errors
  • section
  • form
  • link.*

Related issues

related to TYPO3.Fluid - Feature #5033: Improve Shorthand Syntax of ViewHelpers Resolved 2009-10-19

Associated revisions

Revision beaa1450
Added by Bastian Waidelich almost 6 years ago

[+FEATURE] Fluid (ViewHelpers): extended format.date viewhelper by an additional "date" argument. Now you can write {f:format.date(date: 'yesterday')} in your templates. This change is backwards compatible! Relates to #5150
[+FEATURE] Fluid (ViewHelpers): extended if viewhelper by arguments "then" and "else". Now you can write {f:if(condition: 1, then: 'yes', else: 'no'} in your templates. This change is backwards compatible! Relates to #5150
[~TASK] Fluid (Core): added check for reserved keywords to TemplateVariableContainer. This relates to #5158
[~TASK] Fluid (Tests): moved and renamed VariableContainerTest

History

#1 Updated by Sebastian Kurfuerst almost 6 years ago

Hey :-)

With the f:format.crop example, I don't really see why this should be needed :-) You can just crop it manually in that case ;)

I'd be curious what example really make sense in this context.

Greets and all the best,
Sebastian

#2 Updated by Bastian Waidelich almost 6 years ago

  • Subject changed from Support static strings in inline notation to Rewrite ViewHelpers to support new inline notation
  • Assigned To set to Bastian Waidelich

UPDATE:
We've decided to rewrite the affected view helpers instead.
That is:

uri.resource:
from
{foo -> f:uri.resource()}
to
{f:uri.resource(path: foo)}
(already done in r3354)

cObject (v4 only):
from
{foo -> f:cObject(typoscriptObjectPath: 'lib.myCustomCObject')}
to
{f:cObject(data: foo, typoscriptObjectPath: 'lib.myCustomCObject')}

format.date:
from
{foo -> f:format.date(format: 'Y')}
to
{f:format.date(date: foo, format: 'Y')}

translate:
from
{foo -> f:translate(key: 'bar')} // here, {foo} would be the fallback - not very intuitive
to
{f:translate(default: foo, key: 'bar')}

#3 Updated by Bastian Waidelich almost 6 years ago

  • Status changed from New to Resolved

Resolved in r3365

Also available in: Atom PDF