Templates
Templates in SurveyCompo let you reuse survey components across various Pages or Blocks, which helps keep everything consistent. If you notice you're repeating the same settings or keys on different pages or blocks, you can create a template for those keys. Then, you can reuse the template wherever needed. Any changes you make to the template will automatically update all the pages or blocks using it.
To define a template in SurveyCompo, use the pageTemplates
and blockTemplates
keys in the survey model. The pageTemplates
key holds an array of page models that can be used as templates, while the blockTemplates
key holds an array of block models for the same purpose. Each template is given a unique name using the templateName
key.
The following example defines an page template with a footer and applied to multiple pages:
Block templates work similarly to page templates, allowing you to define and reuse them across multiple blocks.
Note
The inputs
and blocks
keys in templates are ignored. This means you cannot use templates to repeat the same set of questions across multiple pages or blocks.