HANDLEBARSTEMPLATE content object
HANDLEBARSTEMPLATE is a custom content object type provided by
this extension. It compiles and renders a Handlebars template, resolving
template paths, processing variables, and registering assets — all from
TypoScript configuration.
tt_content.header = HANDLEBARSTEMPLATE
tt_content.header {
templateName = Header
templateRootPaths.20 = EXT:my_extension/Resources/Private/Templates
}
Properties
templateName
- Type
- string / stdWrap
- Description
- Name of the template to render. The value is resolved as a filename
(without the
.hbsextension) relative to the configured template root paths. Exactly one oftemplate,Name template, orfilemust be set. - Example
templateName = Header # With stdWrap templateName.field = tx_myext_template_nameCopied!
template
- Type
- string / stdWrap
- Description
- Inline Handlebars source used directly as the template. Useful for short
or dynamically constructed templates. Cannot be used together with
templateorName file. - Example
template = <h1>{{header}}</h1>Copied!
file
- Type
- string / stdWrap
- Description
- Absolute or
EXT:-relative path to a Handlebars template file. Cannot be used together withtemplateorName template. - Example
file = EXT:my_extension/Resources/Private/Templates/Special.hbsCopied!
templateRootPaths
- Type
- array (numeric keys)
- Description
- Template root paths for this content object. These are added to the content object path provider with the highest priority (100), overriding any TypoScript or service container paths for this rendering. Higher numeric keys take precedence over lower ones.
- Example
templateRootPaths { 10 = EXT:my_extension/Resources/Private/Templates 20 = EXT:my_other_extension/Resources/Private/Templates }Copied!
Note
The shorthand
template (singular) sets a single
path at key 0.
partialRootPaths
- Type
- array (numeric keys)
- Description
- Partial root paths for this content object. Same priority and override
rules as
template.Root Paths - Example
partialRootPaths { 10 = EXT:my_extension/Resources/Private/Partials }Copied!
Note
The shorthand
partial (singular) sets a single
path at key 0.
variables
- Type
- array
- Description
-
Variables passed to the template. Each entry is processed as a content object against the current content element's data record. Simple string values are passed through as-is; entries with a sub-array are rendered via
Content.Object Renderer:: c Obj Get Single () Two variable names are reserved and always available automatically:
data— the full content element data arraycurrent— the current field value
- Example
variables { header = TEXT header.field = header bodytext = TEXT bodytext.field = bodytext bodytext.parseFunc < lib.parseFunc_RTE image = FILES image.references.fieldName = image }Copied!
settings
- Type
- array
- Description
- Arbitrary key-value pairs passed to the template as the
settingsvariable. Unlikevariables, entries are not processed as content objects — values are used as plain strings. - Example
settings { showDate = 1 dateFormat = d.m.Y }Copied!In the template:
{{#if settings.showDate}} <time>{{formatDate date settings.dateFormat}}</time> {{/if}}Copied!
dataProcessing
- Type
- array
- Description
-
Standard data processors, executed after
variablesare resolved. Processors receive and return the$processedarray. Any key added by a processor is available as a template variable.Data The extension provides three additional processors:
process-,variables resolve-, andmarkers unflatten-.variable- names - Example
dataProcessing { 10 = database-query 10 { table = tx_myext_domain_model_item as = items } 20 = process-variables 20 { as = items merge = 1 variables { label = TEXT label.field = title } } }Copied!
See also
Data processors for documentation of the extension-specific processors.
preProcessing
- Type
- array
- Description
- Data source aware processors executed before
variablesare processed. These can read from multiple data sources (content element record, processed data, processor configuration) and modify the variable set before content object rendering begins.
postProcessing
- Type
- array
- Description
- Data source aware processors executed after
variableshave been resolved and data processors have run, but before the template is rendered.
assets
- Type
- array
- Description
- Registers JavaScript and CSS assets via TYPO3's AssetCollector API. Supports
four sub-keys:
java,Script inline,Java Script css,inline.Css - Example
assets { javaScript { my-ext-app { source = EXT:my_extension/Resources/Public/JavaScript/app.js attributes.defer = 1 options.useNonce = 1 } } css { my-ext-styles { source = EXT:my_extension/Resources/Public/Css/styles.css } } }Copied!
See also
Asset management for the complete assets configuration reference.
headerAssets
- Type
- content object
- Description
- Adds arbitrary markup to the page
<head>. The value is evaluated as a content object and the result is passed toPage.Renderer:: add Header Data () - Example
headerAssets = TEXT headerAssets.value = <link rel="stylesheet" href="/assets/styles.css">Copied!
stdWrap
- Type
- stdWrap
- Description
- Standard TYPO3 stdWrap processing applied to the final rendered output.
- Example
stdWrap.wrap = <div class="handlebars-content">|</div>Copied!