Create and reuse a stencil
Create a reusable document part, write its content, give it parameters, and use it in several templates.
User guide navigation
On this page
Before you begin
Use a stencil for a letterhead, signature, address layout, legal paragraph, or other part you use in several templates. To build one, you need:
- Content Author access
- a catalog you can change
- a template you can open in the editor
A template uses a stencil by reference. It does not store a copy. When you change the stencil, every template that uses it shows the change.
A stencil has no versions of its own. It is part of the catalog’s next release, and Publish… publishes it with the rest. To publish the catalog, you need Content Publisher access.
Create the stencil
- Open the catalog, then its Stencils page, and choose New stencil.
- Enter a Name, such as Letter signature. Epistola fills in the Stencil ID. You can add a description and tags.
- Choose Create stencil. The stencil’s page opens. The stencil has no content yet.
The stencil’s page shows its ID, tags, readiness, parameters, and the templates that use it. It has no content editor. You write the content in a template editor.
Write the content
- Open a template variant in the editor. Add a Stencil block, choose your stencil, and choose Insert. The block is empty, because the stencil has no content yet.
- Select the block and choose Edit Stencil. The inspector says that you are editing the stencil itself, and that saving changes it in every template that uses it.
- Drag a Text block or other blocks from Blocks onto the stencil’s content area. A click in Blocks adds a block at the end of the template instead.
- Choose Save Stencil. Or choose Save and Mark Ready to save and check the stencil at once.
- Choose Stop Editing. The block shows the stencil as it was last saved. Changes you did not save are dropped.
Mark ready is an early check. You can also use it on the stencil’s page. Publishing the catalog checks every stencil anyway.
Use the stencil in another template
In another template, add a Stencil block, choose the stencil, and choose Insert. The picker lists stencils, not versions. The template stores only the reference and the values you give it.
To change the stencil, select any block that uses it and choose Edit Stencil. Make the change, choose Save Stencil, then Stop Editing. Every template that uses the stencil shows the change straight away. There is nothing to upgrade.
Because one change reaches every template, check who uses a stencil before you change it. On the stencil’s page, Templates using this stencil lists each template, its variant, and the number of instances. Fits says whether the template still matches the stencil. A template that Does not fit, for example because it binds a parameter that was renamed, blocks publishing until you fix that template.
To use a stencil from another catalog, your catalog must declare that catalog as a dependency.
Give the stencil an input
An example: a greeting you use in several templates.
- Select a block that uses the stencil and choose Edit Stencil, then Define parameters….
- Choose + Add parameter. Enter the name
recipientNameand the type Text. Decide whether it is Required. If the parameter is optional, give it a useful default. - Choose Save.
- In the inspector’s Parameters section, choose Configure parameters…. In the
recipientNamerow, enter a field of the template’s data contract, such ascustomerName. Choose Save. - Drag a Text block onto the stencil’s content area. Type
{{, switch to Code, enterparams.recipientName, and choose Save. - Choose Save Stencil and Stop Editing.
- Preview the result with a few examples.
You cannot mark a template variant ready while it uses the stencil without binding a required parameter with Configure parameters…. You can still save it.
Let the stencil read the template’s data
By default, a stencil’s content sees only its parameters. On the stencil’s page, turn on Its content also reads the using template’s data if the content should use the template’s fields directly. Parameters keep the stencil independent of one template, so prefer them when you can.
Leave room for template content
A Placeholder block marks a spot in the stencil where each template adds its own blocks. You give it a name, and you can give it default content for templates that leave it empty. A placeholder can also pass the stencil’s parameters to the content the template adds.
Nest stencils and detach
A stencil can contain other stencils, up to five levels deep. For example, a letter shell can contain a letterhead stencil.
Detach from Stencil turns the block into ordinary content in this template. It then no longer follows the stencil. Use it only when this template really needs its own version.
You cannot delete a stencil that a template or another stencil still uses. Epistola names the templates and stencils that still use it. If publishing is blocked, see Publishing problems.
Documentation
Guided tour
Epistola is open source, not free of cost. The organisations that use it fund its development, through Epistola or an Official Partner. We are steward-owned: fair prices, no profit maximisation. How Epistola is funded →