Summary (version 3.1.1)
Demo Readme Changelog Buy this module

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.1.1

Add support for lists in subtemplates (ordered lists and unordered lists).

3.1.0

Import styles in the case when the included document defines some styles.

3.0.1

Handle images importing

3.0.0

Initial release

You can buy only this module by using following link : Buy this module

Edgar Hipp

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