Code blocks
Curly braces can be used to structure identifier paths in a more efficient way: Without repeating upper parts of a path in each line. This allows nesting.
Example without braces:
myIdentifier = TEXT
myIdentifier.stdWrap.field = title
myIdentifier.stdWrap.ifEmpty.data = leveltitle:0
This can be written as:
myIdentifier = TEXT
myIdentifier {
stdWrap.field = title
stdWrap.ifEmpty.data = leveltitle:0
}
Curly braces can be nested to further improve readability. This is also the same as above:
myIdentifier = TEXT
myIdentifier {
stdWrap {
field = title
ifEmpty {
data = leveltitle:0
}
}
}
Some rules apply during parsing:
- Everything on the same line after the opening
{
and closing}
brace is considered a comment, even if the comment markers#
,//
and/* ... */
are missing. -
The closing brace
}
must be on a single line in order to close a block. The following construct is invalid, the closing brace is interpreted as part of the value, so the TypoScript and TSconfig backend modules will mumble with a "missing closing brace" warning:myIdentifier = TEXT myIdentifier { value = bar }
Copied! -
Conditions can not be placed within blocks, they are always "global" level and stop any brace nesting. The following construct is invalid, the TypoScript and TSconfig backend modules will mumble with a "missing closing brace" warning:
myIdentifier = TEXT myIdentifier { value = foo [frontend.user.isLoggedIn] value = bar [end] }
Copied! -
Nesting is per-file / per-text-snippet: It does not "swap" into included files. This was the case with the old TypoScript parser. It has been a nasty side-effect, leading to hard to debug problems. File includes with
@import
within curly braces are not relative (anymore).A construct like this is invalid, the TypoScript and TSconfig backend modules will mumble with a "missing closing brace" warning:
myIdentifier = TEXT myIdentifier { @import 'EXT:my_extension/Configuration/TypoScript/bar.typoscript' value = foo }
Copied!