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
}
Copied!

templateName 

Type
string / stdWrap
Description
Name of the template to render. The value is resolved as a filename (without the .hbs extension) relative to the configured template root paths. Exactly one of templateName, template, or file must be set.
Example
templateName = Header

# With stdWrap
templateName.field = tx_myext_template_name
Copied!

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 templateName or 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 with templateName or template.
Example
file = EXT:my_extension/Resources/Private/Templates/Special.hbs
Copied!

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!

partialRootPaths 

Type
array (numeric keys)
Description
Partial root paths for this content object. Same priority and override rules as templateRootPaths.
Example
partialRootPaths {
    10 = EXT:my_extension/Resources/Private/Partials
}
Copied!

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 ContentObjectRenderer::cObjGetSingle().

Two variable names are reserved and always available automatically:

  • data — the full content element data array
  • current — 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 settings variable. Unlike variables, 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 variables are resolved. Processors receive and return the $processedData array. Any key added by a processor is available as a template variable.

The extension provides three additional processors: process-variables, resolve-markers, and 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!

preProcessing 

Type
array
Description
Data source aware processors executed before variables are 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 variables have 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: javaScript, inlineJavaScript, css, inlineCss.
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!

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 to PageRenderer::addHeaderData().
Example
headerAssets = TEXT
headerAssets.value = <link rel="stylesheet" href="/assets/styles.css">
Copied!

footerAssets 

Type
content object
Description
Adds arbitrary markup before the closing </body> tag. The value is evaluated as a content object and the result is passed to PageRenderer::addFooterData().
Example
footerAssets = TEXT
footerAssets.value = <script src="/assets/app.js"></script>
Copied!

stdWrap 

Type
stdWrap
Description
Standard TYPO3 stdWrap processing applied to the final rendered output.
Example
stdWrap.wrap = <div class="handlebars-content">|</div>
Copied!