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/stdWrapThe template that is used for rendering.
- templateRootPaths
Type
string/stdWrapThe 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
dataandcurrent, which are filled automatically with the current data set.- settings
Type
arraySets the given settings array in the Twig template.
- dataProcessing
Type
arrayAdd 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
arrayThe file loader shipped with Twig allows to register namespaced folders. A namespace can be referenced with
@namespacefollowed 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/componentscan be referenced using the namespace. The template name will looks like@myComponents/text_and_media.html.twig.