TWIGTEMPLATE¶
With this Content Object a template file (e.g. a HTML file) is rendered. The functionality is close to FLUIDTEMPLATE.
Properties¶
- templateName
Type
string
/stdWrap
The template that is used for rendering.
- templateRootPaths
Type
string
/stdWrap
The root directories for the loader to look in.
- variables
Type
cObject[]
Sets variables that should be available in the Twig template. The keys are the variable names.
Reserved variable names are
data
andcurrent
, which are filled automatically with the current data set.- settings
Type
array
Sets the given settings array in the Twig template.
- dataProcessing
Type
array
Add one or multiple processors to manipulate the variables that will be passed to the template engine. The sub- property options can be used to pass parameters to the processor class.
Example:
page.10 = TWIGTEMPLATE page.10 { templateName = EXT:site_package/Resources/Private/TwigTemplates/template.html.twig dataProcessing { 1 = Vendor\YourExtensionKey\DataProcessing\MyFirstCustomProcessor 2 = Vendor2\AnotherExtensionKey\DataProcessing\MySecondCustomProcessor 2.options { myOption = SomeValue } } }
The build-in data processors are documented here.
- namespaces
Type
array
The file loader shipped with Twig allows to register namespaced folders. A namespace can be referenced with
@namespace
followed by the path to the template.Example:
page.10 = TWIGTEMPLATE page.10 { templateName = @myComponents/text_and_media.html.twig namespaces { myComponents { 10 = EXT:example_site/Private/frontend/src/components } } }
The given code example defines a namespace called
myComponents
. A template that is located inEXT:example_site/Private/frontend/src/components
can be referenced using the namespace. The template name will looks like@myComponents/text_and_media.html.twig
.