Documentation and demo for module subtemplate


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.


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);
		header: headerDoc,
		footer: footerDoc,
const subtemplateModule = new SubtemplateModule();
const output = doc.render().getZip();

Have any questions ? Contact us at

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.