Feature #43356

Allow Fluid arrays only in ViewHelper arguments

Added by Sebastian Kurfuerst over 2 years ago. Updated over 2 years ago.

Status:Resolved Start date:2012-11-27
Priority:Should have Due date:
Assigned To:Sebastian Kurfuerst % Done:

100%

Category:Core
Target version:-
Has patch:No

Description

Allow Fluid arrays only in ViewHelper arguments

The following proposal would greatly enhance JavaScript compatibility:

Fluid Arrays are a subset of the JavaScript object syntax, making it
hard to work with them in mixed HTML/JavaScript documents. For example
before this change, the following JavaScript Object was parsed by Fluid:

var uris = {
endPoint1: '{f:uri.action(…)}',
endPoint2: '{f:uri.action(…)}',
};

Before this change, the above snippet resulted in the following template, as the generated array was casted to a string:

var uris = Array

With this change, Fluid only parses arrays which are used inside
ViewHelper arguments, such that an array inside normal text is not
converted anymore.

Breaking Change

This change is only breaking in very rare cases where one relied on
the inner contents of the ViewHelper being an array, f.e. if one used
the debug ViewHelper as follows:

<f:debug>{key1: 'value1', key2: 'value2'}</f:debug>

… or if anybody wrote custom ViewHelpers which use this convention.

Relying on that would be very fragile anyways, as the insertion of a
single space character before the opening curly bracket or after the
closing one would cast the array back to a string.

ViewHelpers which were written like this should be re-written to take
the array as ViewHelper argument:

<f:debug value="{key1: 'value1', key2: 'value2'}" />

Related issues

related to TYPO3.Fluid - Feature #7608: Configurable shorthand/object accessor delimiters New 2010-05-03
related to TYPO3.Fluid - Bug #44140: Unlucky JavaScript syntax can break inline tags Resolved 2012-12-20
duplicated by TYPO3.Fluid - Bug #45071: Fluid tries to parse inside an in-HTML Javascript code Closed 2013-02-01

Associated revisions

Revision ba09ec53
Added by Sebastian Kurfuerst over 2 years ago

[!!!][FEATURE] Allow Fluid arrays only in ViewHelper arguments

This change greatly enhances the JavaScript compatibility of Fluid.

Fluid Arrays are a subset of the JavaScript object syntax, making it
hard to work with them in mixed HTML/JavaScript documents. For example
before this change, the following JavaScript Object was parsed by Fluid::

var uris = {
endPoint1: '{f:uri.action(…)}',
endPoint2: '{f:uri.action(…)}',
};

Before this change, the above snippet resulted in the following template,
as the generated array was casted to a string:

var uris = Array

With this change, Fluid only parses arrays which are used inside
ViewHelper arguments, such that an array inside normal text is not
converted anymore.

Breaking Change ===============

This change is only breaking in very rare cases where one relied on
the inner contents of the ViewHelper being an array, f.e. if one used
the debug ViewHelper as follows::

<f:debug>{key1: 'value1', key2: 'value2'}</f:debug>

… or if anybody wrote custom ViewHelpers which use this convention.

Relying on that would be very fragile anyways, as the insertion of a
single space character before the opening curly bracket or after the
closing one would cast the array back to a string.

ViewHelpers which were written like this should be re-written to take
the array as ViewHelper argument::

<f:debug value="{key1: 'value1', key2: 'value2'}" />

Change-Id: I5a54a50dd1bb365486c6f59efcb966dc4e441c79
Resolves: #43356
Releases: 1.2

History

#1 Updated by Sebastian Kurfuerst over 2 years ago

  • Category set to Core
  • Status changed from New to Accepted
  • Assigned To set to Sebastian Kurfuerst
  • % Done changed from 0 to 80

#2 Updated by Gerrit Code Review over 2 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/16818

#3 Updated by Gerrit Code Review over 2 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/16818

#4 Updated by Gerrit Code Review over 2 years ago

Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/16818

#5 Updated by Gerrit Code Review over 2 years ago

Patch set 4 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/16818

#6 Updated by Sebastian Kurfuerst over 2 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 80 to 100

Also available in: Atom PDF