Variables 

Template variables are available at two scopes: globally for every rendering, and locally for a single content object rendering.

Global variables 

Global variables are merged into every template rendering automatically. They can be defined through TypoScript or the service container.

Via TypoScript 

Use plugin.tx_handlebars.variables to define variables available on every page where the TypoScript is active:

plugin.tx_handlebars {
    variables {
        publicPath = /assets
        siteName = My Site
    }
}
Copied!

Via service container 

Variables can also be defined instance-wide through Services.yaml. These apply regardless of TypoScript configuration:

Configuration/Services.yaml
handlebars:
  variables:
    publicPath: /assets
    apiEndpoint: https://api.example.com
Copied!

Per-rendering variables 

Variables scoped to a single rendering are declared in the variables property of a HANDLEBARSTEMPLATE content object. Each entry is processed as a standard content object against the current record's data:

tt_content.header = HANDLEBARSTEMPLATE
tt_content.header {
    templateName = Header

    variables {
        header = TEXT
        header.field = header

        subheader = TEXT
        subheader.field = subheader

        link = TEXT
        link.typolink.parameter.field = header_link
    }
}
Copied!

Entries with no sub-configuration are treated as simple variables and passed to the template as-is, without invoking ContentObjectRenderer:

variables {
    # Content object — field value is rendered via cObjGetSingle
    header = TEXT
    header.field = header

    # Simple variables — values are passed through directly
    cssClass = my-element
    theme = dark
}
Copied!

Two variables are always injected automatically and cannot be overridden (this reflects the same behavior as in FLUIDTEMPLATE):

data
The full data array of the current content element record.
current
The value of the current field ( $cObj->currentValKey).