Documentation and demo for module subtemplate

Summary

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();

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.