Skip to content

obsidian/components/templates-language-component

Contains class TemplatesLanguageComponent that registers a Prism language highlighting {{token}} / {{token:format}} placeholders.

The language is Obsidian core’s own, not a fleet invention. {{token:format}} is the syntax core’s Templates plugin defines, verified in the shipped app rather than recalled — obsidian.asar/i18n.js, the templates: block:

optionTemplateDateFormatDescription: '{{date}} in the template file will be replaced with this value.'
optionTemplateDateFormatDescription2: 'You can also use {{date:YYYY-MM-DD}} to override the format once.'
optionTemplateTimeFormatDescription: '{{time}} in the template file will be replaced with this value.'
optionTemplateTimeFormatDescription2: 'You can also use {{time:HH:mm}} to override the format once.'

That matters for anyone tempted to change the delimiters: they are not ours to change. A plugin extends core’s language with its own token vocabulary, it does not define a competing one.

Beware the near-miss on that evidence. A grep for {{...}} across the app bundle returns many hits that prove nothing, because Obsidian’s UI strings are i18next and {{...}} is i18next’s own interpolation syntax. The load-bearing hit is the templates: block quoted above — the core plugin’s user-facing settings description. Read that block; do not count braces.

What a consumer varies is only its vocabulary, which is why this component is parameterized rather than fixed: the language id it registers under, the characters a token name may contain, the shape of the format half, and any extra top-level tokens its own template dialect needs.

ClassDescription
TemplatesLanguageComponentRegisters a Prism language highlighting the \{\{token\}\} / \{\{token:format\}\} placeholders of a plugin’s tokenized-string templates.
InterfaceDescription
TemplatesLanguageComponentConstructorParamsParameters for the TemplatesLanguageComponent constructor.
TypeDescription
TemplatesLanguageComponentFormatSourceThe format half of a \{\{token:format\}\} placeholder. - A RegExp describes a scalar format — core’s own shape, e.g. the YYYY-MM-DD of \{\{date:YYYY-MM-DD\}\} — and is wrapped into a string-aliased token. - A PrismTokenObject describes a structured format, used verbatim, so a dialect whose format half is an object rather than a word can supply its own inside grammar and extent pattern. - A factory is the structured form for a dialect that must nest an already registered Prism language into that inside — it receives the loaded Prism module, so the consumer never calls loadPrism.