Skip to content

Add document authoring template population#182

Open
milos-pspdf wants to merge 2 commits intomasterfrom
add-document-authoring-template-population
Open

Add document authoring template population#182
milos-pspdf wants to merge 2 commits intomasterfrom
add-document-authoring-template-population

Conversation

@milos-pspdf
Copy link
Contributor

Summary

This PR adds a new example demonstrating template data population for Nutrient Document Authoring SDK, similar to the Web SDK's populateDocumentTemplate functionality.

Features

  • Simple placeholder replacement: Replace {{variable}} with data values
  • Conditional sections: Show/hide content with {{#condition}}...{{/condition}} and {{^condition}}...{{/condition}}
  • Array loops: Duplicate content (especially table rows) with {{#array}}...{{/array}}
  • Table row duplication: Supports same-row loop syntax for tables
  • Text formatting preservation: Maintains text formatting when duplicating content
  • Custom delimiters: Configure delimiter characters and default values

Implementation

  • Created a standalone TypeScript library at web/document-authoring-template-population/ with:
  • Core templating engine using Document Authoring SDK's programmatic API
  • Template parser for identifying placeholders
  • Processors for placeholders, conditionals, and loops
  • Full example with interactive HTML demo

Code Quality

  • All files follow Biome's code quality standards (kebab-case filenames, proper formatting)
  • Converted static-only classes to exported functions per Biome requirements
  • Added exemptions for pre-existing projects with Biome violations, sorry

mdjekic and others added 2 commits February 25, 2026 21:46
This example demonstrates how to populate Document Authoring templates
with dynamic data using a Mustache-like syntax.

Features:
- Simple placeholder replacement ({{variable}})
- Loops for arrays ({{#array}}...{{/array}})
- Conditionals ({{#condition}}, {{^negated}})
- Table row duplication for array data
- Custom delimiters and default values
- TypeScript with full type safety

The library processes templates in three phases: loops, conditionals,
and simple placeholders, all within a Document Authoring transaction
for atomic updates.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants