Bug #5150

Rewrite ViewHelpers to support new inline notation

Added by Bastian Waidelich over 12 years ago. Updated over 11 years ago.

Status:
Resolved
Priority:
Should have
Category:
Core
Target version:
-
Start date:
2009-10-27
Due date:
% Done:

0%

Estimated time:
Has patch:

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 ViewHelpersResolvedSebastian Kurfuerst2009-10-19

Actions
#1

Updated by Sebastian Kurfuerst over 12 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 over 12 years ago

  • Subject changed from Support static strings in inline notation to Rewrite ViewHelpers to support new inline notation
  • Assignee 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 over 12 years ago

  • Status changed from New to Resolved

Resolved in r3365

Also available in: Atom PDF