Skip to content
Snippets Groups Projects
Commit 66d053f6 authored by Claus Due's avatar Claus Due Committed by waldhacker
Browse files

[TASK] Move EXT:form inline JS from template to controller

Allows compatibility with Fluid 3.x.

The change is necessary because Fluid 3.x moves away from regular
expression to detect Fluid syntax, while also allowing more detailed
customisations of what can be written as inline syntax. The result
is that the JSON object notation gets seen as Fluid syntax. Even if
Fluid 3.x natively was more permissive about such embedding, combining
it with calls to Fluid ViewHelpers would still present problems (when
is a curly brace JSON and when is it Fluid? Do we process Fluid tag
notation only inside strings in that JSON? How aware should Fluid be,
not just of JSON but potentially also embedded XML? And can we accept
a considerable increase in Fluid's internal complexity to handle these
edge cases for any conceivable embedding strategy?). In order to avoid
this complexity, Fluid 3.x pragma has been to make it intentionally
more naive, at the cost of potentially detecting syntax that in 2.x
would not be detected as Fluid syntax.

As a side note: there *is* a standard way to tell Fluid "this syntax
isn't Fluid" - by prefixing curly brace statements with a backslash -
but this approach is not compatible with Fluid 2.x which would simply
output the backslash, resulting in invalid JSON syntax.

Essentially, while we keep support for Fluid 2.x we are slightly more
constrained in what we can choose to embed in Fluid, because whatever
we choose to embed, must be compatible with both versions.

And though there *are* certain ways we could accommodate JSON-in-Fluid,
none of them are straight-forward and may in the end only encourage
less than ideal practices (such as embedding script tags with Fluid
being used to build variables - which is something that ideally should
be handled in a controller, and in TYPO3 context, integrated via the
PageRenderer instead of appearing at arbitrary places in DOM).

So even though much more detailed explanations/workarounds are possible,
TYPO3 CMS should constitute a best-practice reference and be as
compatible as we possibly can - which in this case means not embedding
Fluid-processed JSON in templates, but rather use the controller and
PageRenderer to do such embedding.

A similar change was done to embed the "goTo_altDoc" JS function in
the page module, to pass the entire function as Fluid variable instead
of passing only the function body as variable. PageRenderer was not
used for that, since the function was rendered as part of a modal which
does not use PageRenderer for output - since PageRenderer is available
in context of the Form module, it is preferable to use that strategy.

Releases: master
Resolves: #90867
Change-Id: I6ea8dda6e6900b236a7801020f796f05c0b0d9b2
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63965


Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarBjörn Jacob <bjoern.jacob@tritum.de>
Tested-by: default avatarwaldhacker <hello@waldhacker.dev>
Reviewed-by: default avatarBjörn Jacob <bjoern.jacob@tritum.de>
Reviewed-by: default avatarwaldhacker <hello@waldhacker.dev>
parent 02c2b6e7
Branches
Tags
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment