[TYPO3-50-general] TypoScript 2.0 - literals and variables
Robert Lemke
robert at typo3.org
Wed Jun 13 10:45:00 CEST 2007
Hi folks,
last night I've been working a bit on the matching pattern for
literals and variables in value assignments. Here's an example which
follows the current definition as found in the documentation:
myObject = Text
myObject.$part1 = "Hello"
myObject.$part2 = "world"
myObject.value = $part1 . " " . $part2 . "!"
The rules for values basically follows the PHP syntax, you have
variables ($part1), literals (" ") and may concatenate them with a dot.
Now, it turned out that this is a bit difficult to match (although I
finally managed to create a regex for that). Therefore I thought
about changing the rules again. What about these examples:
myObject = Text
myObject.$part1 = "Hello"
myObject.$part2 = "world"
myObject.value = "$part1 $part2!"
myOtherObject = Text
myOtherObject.$message = "Hello world!"
myOtherObject.value = $message
That means, we refrain from introducing the "." operator and matching
the content of what is enclosed by quotes is much easier. And it is
less typing. On the other hand you must escape the dollar sign if you
want to use it in a string.
myObject.value = "This surf board costs \$ 950"
Contrary to PHP, I would allow variables in both, strings enclosed by
double quotes and by single quotes.
myObject.value = "$part1 $part2!"
myObject.value = '$part1 $part2!'
What do you think?
robert
--
http://typo3.org/gimmefive
More information about the TYPO3-project-5_0-general
mailing list