Quick start
This page walks through a minimal working example: rendering the header
CType with a Handlebars template.
-
Include site sets
The extension ships two site sets. Include them in your site's configuration via the site module or
config/.sites/<site>/ sets. yaml cpsit/(required)handlebars - Wires
plugin.paths from the site settingstx_ handlebars. view handlebars.andview. template Root Path handlebars.. Required for every site that renders Handlebars templates.view. partial Root Path cpsit/(optional)handlebars- content- element - Sets
lib., replacing the default Fluid base object. Include this set when all content elements should use Handlebars rendering by default.content Element = HANDLEBARSTEMPLATE
-
Configure template paths
Declare where your
.hbsfiles are located. The simplest option is TypoScript:plugin.tx_handlebars { view { templateRootPaths { 10 = EXT:my_sitepackage/Resources/Private/Templates/Handlebars } partialRootPaths { 10 = EXT:my_sitepackage/Resources/Private/Partials/Handlebars } } }Copied!See also
Template paths — all configuration methods and their priority order.
-
Create a Handlebars template
Create the template file at the path declared above. The filename without the
.hbsextension is used as thetemplate:Name EXT:my_sitepackage/Resources/Private/Templates/Handlebars/Header.hbs<div class="ce-header"> {{#if header}} <h1 class="ce-header__title">{{header}}</h1> {{/if}} {{#if subheader}} <p class="ce-header__subtitle">{{subheader}}</p> {{/if}} </div>Copied! -
Configure the content element
Point the
headerCType at the template using aHANDLEBARSTEMPLATEcontent object:tt_content.header = HANDLEBARSTEMPLATE tt_content.header { templateName = Header variables { header = TEXT header.field = header subheader = TEXT subheader.field = subheader } }Copied!Each entry in
variablesis processed as a TYPO3 content object against the current content element record. The resulting values are passed to the template alongside the automatically injecteddataandcurrentvariables. -
Flush caches
After editing TypoScript, flush the TYPO3 page cache. After editing
Services., flush and rebuild the service container as well.yaml
Next steps
- HANDLEBARSTEMPLATE content object — complete reference for all
HANDLEBARSTEMPLATEproperties - Data processors — enrich templates with database queries, menus, and custom variable processing
- Custom helpers — expose custom PHP logic to templates