Skip to content

Template Engine

Choose a tag to compare

@GitHubNewbie0 GitHubNewbie0 released this 24 Feb 23:19
· 391 commits to main since this release

Template Engine
v0.3.0 adds a template engine to odf-kit. Create a .odt template in LibreOffice with {placeholders}, fill it with data from JavaScript.
Added

Template engine — fillTemplate() loads an existing .odt, replaces {placeholders} with data, returns a new .odt
Loops — {#items}...{/items} repeats content for each array item
Conditionals — {#showSection}...{/showSection} includes/removes based on truthy/falsy
Dot notation — {user.address.city} for nested data
Placeholder healer — automatically reassembles placeholders fragmented by LibreOffice across text:span elements
Boundary expansion — section markers expand through wrapping XML to prevent orphaned tags
Header/footer templates — placeholders in headers and footers processed alongside body
120 new tests — 222 total

See CHANGELOG.md for full details.