Snippets
Snippets (text modules) are reusable content blocks that can be inserted into templates. They allow you to maintain commonly used content in one place and reference it across multiple templates.
Types of Snippets
primedocs supports two main snippet types:
- WordContent: Reusable Word content blocks that can include text, tables, images and other complex Word content. Used when you need to dynamically insert entire sections of Word content into a document.
- FormattedText: Lightweight HTML-based formatted text snippets. Used for formatted text passages that need consistent formatting across templates, such as header/footer content.
Benefits
- Consistency: Maintain consistent content across all templates from a single source.
- Efficiency: Update content in one place and have it reflected in all templates that use that snippet.
- Dynamic content: Snippets can be made dynamic using JavaScript, allowing them to adapt to user input or profile data.
Usage in Templates
Snippets are used in the Fields document function. They are accessed via the snippets API in JavaScript code:
// WordContent snippet
$.snippets.getWordContent("SnippetName")
// FormattedText snippet
$.snippets.getFormattedText("SnippetName")