Creating Custom Template Helpers
Authors:
Cameron Johns, Cille Schliebitz, Anita Gu
Changed on:
3 Feb 2025
Overview
This lesson explores the creation and registration of custom template helpers within the Component SDK. Template helpers are powerful utilities that can be used within Manifest documents for tasks like styling, formatting, and calculations. We'll demonstrate how to create a custom template helper, in this case, one that bolds entity references, showcasing how to leverage the
`TemplateRegistry`
Key points
- Template Helpers: Template helpers are reusable functions that can be called within Manifest documents to perform various operations.
- Use Cases: Template helpers can be used for styling, formatting, calculations, and other data transformations.
- : The
`TemplateRegistry`
is used to register custom template helpers, making them available for use in Manifests.`TemplateRegistry`
- HTML Formatting: The lesson demonstrates creating a template helper that bolds entity references using utility methods for formatted HTML generation.
`TemplateRegistry`
- Customizability: Custom template helpers extend the functionality of Manifests, allowing for greater flexibility and control over data presentation.
Another useful feature of the Component SDK is the ability to create custom helpers for the Manifest document. The UX Framework provides a number of these as standard, but you can also create and register your own.
You can use them for various things such as:
- Styling
- Formatting
- Calculations
Example:
Let's say that you would like to style all entity references displayed in a specific style, such as bold.
You can create a "bold" template like this:
