Task #48361

Work Package #48275: TypoScript consistency

Kill processor classes; change processor syntax

Added by Sebastian Kurfuerst about 2 years ago. Updated almost 2 years ago.

Status:Resolved Start date:2013-05-17
Priority:Should have Due date:
Assigned To:Sebastian Kurfuerst % Done:

100%

Category:-
Target version:Base Distribution - 1.0 beta 1

Description

the whole team feels that processors are somewhat not fitting into the TS concept; especially because many things can be done as well using Eel; and we want to provide one consistent way of doing things.

This means:

  • we want to remove processor classes; instead the functionality should be made available in the Eel standard library
  • we want the following syntax for processors:
page.title = "foo" 

// short syntax
page.title.@process.wrapInTitle = ${ "before" + value + "after" }

// long position syntax
page.title.@process.wrapInTitle {
  expression = ${ "before" + value + "after" }
  @position = "end 50" 
}
  • positional arguments as known from TypoScript should just work here.
  • we are not yet sure if the "current value" variable should be called "value" or differently. Same, it is not yet clear whether the long form should be called "expression".

Together with #48359 this means one could also write custom TypoScript objects and use them as "processors".

We all think this is more powerful and consistent than the old processor implementation.


Related issues

related to TYPO3.TypoScript - Task #48359: Simple Value / Eel Expression / TypoScript Object Interop... Resolved 2013-05-17

Associated revisions

Revision db4ae808
Added by Rens Admiraal almost 2 years ago

[!!!][FEATURE] re-implement Processors based on TypoScript Objects and Eel

This is a major overhaul of the TypoScript processors feature.

Before this change, processors were written such as::

myProperty = "some text" 
myProperty << 1.wrap(after: '…')

However, then, we introduced Eel objects, and it became more and more clear
that processors, while they are very important from a users standpoint,
lead to very much duplicated code.

That's why we are dropping the above syntax completely, replacing it with
the following:

New Processors ==============

::

myProperty = "some text" 
= ${value + '…'}
  • We use the @process meta-property to run processors.
  • The index afterwards describes the ordering on which processors are applied.
  • "value" is a special context variable available in processors which contains
    the to-be-processed content.

Extended Syntax
---------------

Furthermore, there exists an extended syntax as follows:

myProperty = "some text" 
{
expression = ${value + '…'}
@position = 1
}
  • This allows to use named processors.
  • For @position, every positional argument is valid,
    such as "start", "end", [any number], "before [otherkey]",
    "after [otherkey]". That's extremely powerful!

Using TypoScript Objects or Eel Expressions
-------------------------------------------

Instead of using Eel expressions, you can use arbitrary TypoScript
objects for processing stuff, as in the (contrived) example below::

 = Some.Namespace:SomeTypoScriptObject {
value = ${value + '…'}
}

Unsetting of Processors
-----------------------

Unsetting processors was not possible before; now that's
easily done using the ">" operator::

 >

That also works correctly when being combined with prototype
inheritance.

Using TypoScript Objects in @override
-------------------------------------

Furthermore, this change also adjusts the @override functionality
such that a context variable's value is the return value of a
TypoScript object::

// this worked already before this change:
= ${myOtherVariable + '…'}
// this works now as well:
= Value {
value = ${myOtherVariable + '…'}
}

Code Cleanup
------------

This feature has been developed in a very test-driven manner, every functionality
is well-covered with tests. Additionally, the tests and the code of the
runtime and parser are cleaned up. The following features were removed
as they are obsolete:

  • "old" processor syntax and implementations
  • relicts of TypoScript variables (were non-functional before)
  • relicts of "<<" operator (was non-functional before)

Additionally, the internal representation of TypoScript objects has been
changed a little, to make sure you can also set processors on e.g. simple
strings.

Furthermore, it is now made sure that if e.g. an Eel expression is defined,
this expression overrides a TypoScript object or a simple value which has
existed beforehand on a given TypoScript path. The same has been done as well
for simple values and TypoScript objects. This is to make sure that at any
given TypoScript path, there can only be either a TypoScript object,
or an Eel expression, or a simple type. That improves general stability.

When testing this feature, make sure to check out the related changesets
with the same topic as well.

Resolves: #48361
Resolves: #43752
Change-Id: Iee6b6a839a56416c6d1cc72cd92ece049a3fba1f
Reviewed-on: https://review.typo3.org/24423
Reviewed-by: Sebastian Kurfuerst
Tested-by: Sebastian Kurfuerst
Reviewed-by: Rens Admiraal
Tested-by: Rens Admiraal

History

#1 Updated by Gerrit Code Review almost 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 https://review.typo3.org/24423

#2 Updated by Gerrit Code Review almost 2 years ago

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

#3 Updated by Gerrit Code Review almost 2 years ago

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

#4 Updated by Bastian Waidelich almost 2 years ago

Sebastian Kurfuerst wrote:

Great, looking forward to that ;)

  • we are not yet sure if the "current value" variable should be called "value" or differently.

What about "subject" - we use that a lot in format ViewHelpers and it is more generic than "value".

Same, it is not yet clear whether the long form should be called "expression".

Would it make sense to stress that it's an Eel expression or should that be clear?

Also I'm wondering if the process key ("wrapInTitle" in this example) is used for sorting if @position is not set, or - to put it differently - can I write:

page.title.@process.20 = ${ "a" + value + "b" }
page.title.@process.10 = ${ "c" + value + "d" }

and I would get "ac<value>db" ?

#5 Updated by Gerrit Code Review almost 2 years ago

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

#6 Updated by Sebastian Kurfuerst almost 2 years ago

  • we are not yet sure if the "current value" variable should be called "value" or differently.

What about "subject" - we use that a lot in format ViewHelpers and it is more generic than "value".

OK, we could also do that. I'll open a doodle for that.

Same, it is not yet clear whether the long form should be called "expression".

Would it make sense to stress that it's an Eel expression or should that be clear?

It does not have to be an eel expression, it can as well be a TypoScript object which re-uses "value" (or "subject" if we decide to rename it)

Also I'm wondering if the process key ("wrapInTitle" in this example) is used for sorting if @position is not set, or - to put it differently - can I write:

= ${ "a" + value + "b" }

= ${ "c" + value + "d" }

and I would get "ac<value>db" ?

yes that's the way it works :)

Greets, Sebastian

#7 Updated by Gerrit Code Review almost 2 years ago

Patch set 5 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/24423

#8 Updated by Gerrit Code Review almost 2 years ago

Patch set 6 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/24423

#9 Updated by Gerrit Code Review almost 2 years ago

Patch set 7 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/24423

#10 Updated by Gerrit Code Review almost 2 years ago

Patch set 8 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/24423

#11 Updated by Rens Admiraal almost 2 years ago

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

Also available in: Atom PDF