Documentation and demo for module subtemplate

Summary (version 3.0.1) Demo Readme Changelog

This module adds a tag to include the content of an other docx document (which can be a template itself). This allows you to define subtemplates if your templates share common parts.

This module is available as part of the docxtemplater pro plan.

Demo

Input Output
Data Code
{
    "header": headerDoc,
    "footer": footerDoc
}
const headerDoc = new Docxtemplater().loadZip(new JSZip(headerZip))
const footerDoc = new Docxtemplater().loadZip(new JSZip(footerZip))

const doc = new Docxtemplater();
const inputZip = new JSZip(docX);
doc.loadZip(inputZip)
	.setData({
		header: headerDoc,
		footer: footerDoc,
	});
const subtemplateModule = new SubtemplateModule();
doc.attachModule(subtemplateModule);
const output = doc.render().getZip();

README

Subtemplate Module

This module exposes a tag to include subtemplate. The subtemplate is embeded into your document.

Installation:

You will need docxtemplater v3: npm install docxtemplater

Install this module with npm install --save "$url"

Usage

Your docx should contain the text: {~subtemplate}. You can find a working sample at ./sample.js

Building

You can build the es6 into js by running npm run compile

Testing

npm test

CHANGELOG

3.0.0

Initial release

Have any questions ? Contact us at contact@javascript-ninja.fr


Subscribe to our newsletter and keep up to date on the changes done in docxtemplater.

Edgar Hipp

I'm the creator of docxtemplater. I work on making docxtemplater great since 2013.