Skip to content
This repository was archived by the owner on Aug 5, 2025. It is now read-only.

Conversation

@renovate
Copy link
Contributor

@renovate renovate bot commented Mar 20, 2020

This PR contains the following updates:

Package Change Age Confidence
docxtemplater 3.17.9 -> 3.65.2 age confidence

Release Notes

open-xml-templating/docxtemplater (docxtemplater)

v3.65.2

Compare Source

Bugfix rare issue with expressionparser getIdentifiers : pushArray was not defined correctly.

v3.65.1

Compare Source

For some files that are not created by Microsoft Word or Libreoffice, the following stacktrace would be shown :

TypeError: Cannot read properties of undefined (reading 'asText')
 at Docxtemplater.compile (node_modules/docxtemplater/js/docxtemplater.js:425:48)
 at new Docxtemplater (node_modules/docxtemplater/js/docxtemplater.js:205:12)
 at Object.<anonymous> (test.js:23:19)
 at Module._compile (node:internal/modules/cjs/loader:1529:14)
 at Module._extensions..js (node:internal/modules/cjs/loader:1613:10)
 at Module.load (node:internal/modules/cjs/loader:1275:32)
 at Module._load (node:internal/modules/cjs/loader:1096:12)
 at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:164:12)
 at node:internal/main/run_main_module:28:49

This is now fixed by this version.

v3.65.0

Compare Source

When using the angularparser, with the following tag :

{'(.)'}

The default behavior would be that this will return : (this).

It happens because in most expressions, "." is a synonym for this and we can only apply a regex to find all "." and replace them by "this".

For cases where this is not what you want, you can now deactivate this special behavior, so that :

{'(.)'}

Will then show : (.) in the output.

To deactivate the dot handling, use :

const expressionParser = require("docxtemplater/expressions.js");
const doc = new Docxtemplater(zip, {
  paragraphLoop: true,
  linebreaks: true,
  parser: expressionParser.configure({
    handleDotThis: false,
  }),
});
doc.render(/* data */);

v3.64.0

Compare Source

Update in order to make sure that nullGetter is called for section tags (loops or conditions).

The nullGetter will now be called if the template is this :

{#users}
User {name}
{/}

And the data is just {}.

Previously, for loops and conditions, the nullGetter would not be called.

v3.63.4

Compare Source

Move internal methods out of docxtemplater class, into docutils : getRelsTypes, collectContentTypes, getContentTypes.

Upgrade moduleApiVersion to 3.47.0 (for subtemplate module version 3.20.0)

v3.63.3

Compare Source

For xlsx module and the error location module, add the "square" property so that the error "Closing tag does not match opening tag" will now correctly be shown by the error location module.

This requires the latest xlsx module and error location module, ie :

  • Requires error-location-module>=3.9.9
  • Requires xlsx-module>=3.30.1

v3.63.2

Compare Source

Improve patch of 3.63.1 when working with subtemplate module.

v3.63.1

Compare Source

Fix corruption when using the fix-doc-pr-corruption code :

const fixDocPrCorruption = require("docxtemplater/js/modules/fix-doc-pr-corruption.js");

For some very rare templates, that have an "customXml/item1.xml" that uses UTF16 encoding (which is very rare), the output would become corrupt (a dialog would show up to confirm if you want to open the document, and the document would then open correctly).

v3.63.0

Compare Source

Important If you use one of these modules, please make sure to update to the latest version :

  • [table] v3.26.4
  • [qrcode] v3.5.2
  • [pptx-sub] v3.1.12
  • [image] v3.31.5
  • [html] v3.56.8

Change the way xmltemplater.parse and xmltemplater.postparse are called.

Previously, we did :

for (file of files) {
    preparse(file)
}
for (file of files) {
    parse(file)
    postparse(file)
}

Now we do :

for (file of files) {
    preparse(file)
}
for (file of files) {
    parse(file)
}
for (file of files) {
    postparse(file)
}

Add events for before-preparse, after-preparse, after-parse, after-postparse which run like this :

  • before-preparse : before doing all preparse calls
  • after-preparse : after doing all preparse calls (after the for loop)
  • after-parse : after doing all parse calls (after the for loop)
  • after-postparse : after doing all postparse calls (after the for loop)

Update moduleApiVersion to 3.46.0.

When a document had a header that contained a table, if the table rows were specified in the "percent" unit, the following stacktrace would be shown :

Cannot read properties of undefined (reading 'width')
 at collectCellsDimensions (get-dimensions.js)
 at Object.collect (get-dimensions.js)
 at HtmlModule.preparse (index.js)
 at preparse (parser.js)

This is fixed with the following versions : docxtemplater-html-module@v3.56.8, docxtemplater-table-module@v3.26.4, docxtemplater-image-module@v3.31.5

The qrcode and pptx-subtemplate module incorrectly relied on the order of "parse/postparse". With older versions, the output will get quite messed up

You have to update to these versions to make it work :

  • [qrcode] v3.5.2
  • [pptx-sub] v3.1.12

v3.62.2

Compare Source

Bugfix a regression of 3.61.2 when your data contains invalid xml characters.

Since version 3.61.2, in some cases, if two tags contained invalid xml characters, in the Multi Error, only one would be shown.

Now, all invalid xml characters of all tags are shown in the error (this was also the case in versions <= 3.61.1)

v3.62.1

Compare Source

Add correct typescript types for new export functions added in 3.62.0

v3.62.0

Compare Source

Also requires an update to pizzip to at least pizzip@3.2.0

Add multiple export functions : toBuffer, toBlob, toBase64, toUint8Array, toArrayBuffer

Instead of :

const doc = new Docxtemplater(zip, {
  paragraphLoop: true,
  linebreaks: true,
});
doc.render(/* data */);
const buf = doc.getZip().generate({
  type: "nodebuffer",
  /*
   * Compression: DEFLATE adds a compression step.
   * For a 50MB document, expect 500ms additional CPU time.
   */
  compression: "DEFLATE",
});

You can now write :

const doc = new Docxtemplater(zip, {
  paragraphLoop: true,
  linebreaks: true,
});
doc.render(/* data */);
const buf = doc.toBuffer();

It automatically uses "compression": "DEFLATE" (which makes the docx file output smaller but takes a bit of CPU time for the zipping algorithm), and correctly writes the files in the correct order so that the mime type detection for unix systems recognizes the files as the correct mimetypes.

v3.61.2

Compare Source

Correctly remove all corrupt characters when using the stripInvalidXMLChars option.

Previously only the first occurence was removed.

v3.61.1

Compare Source

Update moduleApiVersion to 3.45.0 (for being able to use require("docxtemplater/js/get-tags.js");).

Please update xlsx module to 3.29.1 at least.

Please update slides module to 3.7.1 at least.

v3.61.0

Compare Source

Add doc.getTags() to get tags per document/header/footer.

It works for docx files only

For xlsx files, you need the paid version and use the xlsxModule.getSheets().

For pptx files, you need the paid version and use the slidesModule.getSlides().

v3.60.2

Compare Source

Throw specific error when trying to render a xlsx template to tell you that you have to use the paid xlsx module for that.

v3.60.1

Compare Source

Add typescript typings for expressionParser.configure({setIdentifier: (tag, value, scope, scopeList, context) => true}).

v3.60.0

Compare Source

Make it possible to disable parsing of "{" and "}" completely by setting the delimiters.start and delimiters.end to null.

const doc = new Docxtemplater(zip, {
  delimiters: {
    start: null,
    end: null,
  },
});

Fixed #​777

v3.59.0

Compare Source

Update internal preparse API in order to be able to return a new preparsed value (useful for the new ErrorLocationModule version 3.9.7).

Provides moduleApiVersion 3.44.0 (please update the ErrorLocationModule if you use it).

3.58.4

Make it possible to write unbalanced loops, if specifying the following the option :

const expressionParser = require("docxtemplater/expressions.js");
const doc = new Docxtemplater(zip, {
  paragraphLoop: true,
  linebreaks: true,
  syntax: {
    allowUnbalancedLoops: true,
  },
});
doc.render(/* data */);

Then the following template in a table will work

v3.58.4

Compare Source

Make it possible to write unbalanced loops, if specifying the following the option :

const expressionParser = require("docxtemplater/expressions.js");
const doc = new Docxtemplater(zip, {
  paragraphLoop: true,
  linebreaks: true,
  syntax: {
    allowUnbalancedLoops: true,
  },
});
doc.render(/* data */);

Then the following template in a table will work

v3.58.3

Compare Source

Do not throw an error if sending xml invalid character such as "\u0002" when using TxtTemplater.

v3.58.2

Compare Source

Bugfix Inspectmodule so that it shows image tags inside xlsx files.
Previously, those tags would not appear in the getTags result.

v3.58.1

Compare Source

Add renderAsync typescript typing to TxtTemplater.

v3.58.0

Compare Source

Add renderAsync method to TxtTemplater, usage is like this :

const TxtTemplater = require("docxtemplater/js/text.js");
const doc = new TxtTemplater("Hello {user}, how are you ?");
const result = doc.renderAsync({
  user: new Promise((resolve) => {
    resolve("John");
  }),
});

v3.57.3

Compare Source

When using the stripInvalidXMLChars:true option, if passing a value of a non string, such as :

doc.render({
  first_name: 44,
});

The following stacktrace would be shown :

string.replace is not a function
    at removeCorruptCharacters (es6/doc-utils.js:385:16)"
    at Render.render (es6/modules/render.js:101:12)"
    at moduleRender (es6/render.js:10:33)"

Now, the rendering works correctly.

v3.57.2

Compare Source

Add context parameter to expressionParser :

postEvaluate?: (
    result: any,
    tag: string,
    scope: any,
    context: DXT.ParserContext
) => any;
// context.meta.part will be equal to "name"

v3.57.1

Compare Source

  • Add postEvaluate API to expressionParser.
  • Refactor expandToOne trait

v3.57.0

Compare Source

Add traits.expandToOne.onError for module API to be able to catch or ignore expansion errors.

Provides moduleApiVersion 3.43.0 (please update the HTML module if you use it).

For TxtTemplater, throw XtRenderingError on rendering Error (if the data resolver throws an error), previously a useless stacktrace would be thrown.

v3.56.0

Compare Source

When the data contains control characters, such as "U+0002" (Start of Text) or other control characters, the document would fail to generate.

Docxtemplater now has an option called stripInvalidXMLChars which will strip the bad control characters automatically.

Use it like this :

const doc = new Docxtemplater(zip, {
  stripInvalidXMLChars: true,
  paragraphLoop: true,
  linebreaks: true,
});

v3.55.9

Compare Source

Fix small issues with expressions.js

  • Add compiled property to be able to access the internal expression :

    If the tag is simply : {myVal}

    In your code, you can use :

    const expressionParser = require("docxtemplater/expressions.js");
    const doc = new Docxtemplater(zip, {
      parser: (tag) => {
        const result = expressionParser(tag);
        const firstExpression = result.compiled.ast.body[0].expression;
        expect(firstExpression.type).to.equal("Identifier");
        expect(firstExpression.name).to.equal("myVal");
        expect(firstExpression.constant).to.equal(false);
        return result;
      },
    });
  • Use better error message if using non string value for expressions.js

  • Do not fail if trying to access property of null inside a loop with expressions.js

v3.55.8

Compare Source

Update to fix inspectModule.getAllTags() for all less used modules (qrcode, expand-loop for xlsx).

Use hasOwnProperty.call() for better compatibility.

v3.55.7

Compare Source

Bugfix to fix inspectModule.getAllTags() when using image module ({%image} tag inside alt text) or table merge cell module.

In case when you were using the features of the module, the getAllTags would fail with a stacktrace.

v3.55.6

Compare Source

When using a loop inside a table, if there is a bookmark right after the table, a new empty paragraph would be added.

Now an empty paragraph will not be added in this specific case (an empty paragraph is added between two tables for example, this is mandatory to generate a valid docx document).

v3.55.5

Compare Source

Angular-expressions had a vulnerability (CVE-2024-54152), and was patched at
the same time of the release of docxtemplater@3.55.5.

The new version is angular-expressions@1.4.3.

All users of docxtemplater that use angular-expressions should upgrade to angular-expressions@1.4.3 as soon as possible..

With version angular-expressions@1.4.3 and version<=3.55.4 of docxtemplater, the
following template using this with a computation would not return the correct value

// If the scope is `2`
{this + this} // ✕ Will return undefined with angular-expressions@1.4.3 and docxtemplater@3.55.4
{this + this} // ✓ Will return 4 with angular-expressions@1.4.3 and docxtemplater@3.55.5

// Behavior with older angular-expressions
{this + this} // ✓ Will return 4 with angular-expressions@1.4.2 and docxtemplater@3.55.5
{this + this} // ✓ Will return 4 with angular-expressions@1.4.2 and docxtemplater@3.55.4

Similarly, the following templates would also produce a non correct value :

{this|square}
{. + .}

Most expressions (Probably 99.5%) are not affected and continued to work without an upgrade in docxtemplater, such as {users | filter}, {age > 18}, {company.address}, ...

With version 3.55.5, the correct behavior is restored for the 0.5% cases using this with computations.

v3.55.4

Compare Source

Improve handling of XLSX files for the inspectModule.getTags() function.

It now works correctly with innerloops, like this :

{#l1}    | {#l2}
{name}   | {otherName}
         | {/}{/}

Previously, the "otherName" key would appear as a direct child of l1 (instead of inside l2).

v3.55.3

Compare Source

Hotfix, 3.55.2 was published and did not contain the full fix, 3.55.3 now really fixes the issue with the XlsxModule and odt files.

v3.55.2

Compare Source

Bugfix issue introduced in 3.55.1 when using the XlsxModule and trying to load an odt file, an unexpected error was thrown instead of an error explaining that odt files are not supported.

v3.55.1

Compare Source

Add internal xmlContentTypes API for setting xmlFileNames easily from modules.

Update moduleApiVersion to 3.42.0

v3.55.0

Compare Source

  • Performance improvements : docxtemplater now uses for of loops instead of forEach to avoid creating many anonymous functions.

  • Options immutability : in previous versions, when changing the delimiters.start from the optionsTransformer for one instance, it would change the options for all future doc instances.

    If for some reason, you were changing the DocUtils.defaults, like this, this is no longer possible : (This was not documented anywhere so it is very unlikely that you're doing this).

    require("docxtemplater").DocUtils.defaults.paragraphLoop = true;

    This code will not have any effect starting from 3.55.0, you have to pass the options in the constructor.

  • Refactor InspectModule.getAllTags() to work correctly on xlsx files to properly show nesting of data.

v3.54.1

Compare Source

Bugfix so that "errorChecker" is called when resolveTags fails (and not later in render).

This fixes a bug when using the xlsx + error location module in async mode, so that errors are correctly shown.

v3.54.0

Compare Source

Add console.warn messages when using deprecated methods :

compile, attachModule, setData, resolveData, loadZip

Read more about the migration here

v3.53.0

Compare Source

Add support for replacing placeholders such as {name} in Smart art shapes.

v3.52.0

Compare Source

Add syntax.allowUnclosedTag option.

This allows to write : Hello {user and not have an error in your template.

v3.51.2

Compare Source

Improve typescript typings :

  • Add position and tag to DXT.Part
  • Add void return value to getFileType?(opts: any): string | void;
  • Add targets to Docxtemplater instance

v3.51.1

Compare Source

Update to be able to write {#loop}{. | filter}{/} so that the variable passed
to filter is not of type Proxy.

Previously, the variable passed to the filter would be of type Proxy.

This requires angular-expressions@1.4.0

v3.51.0

Compare Source

Add support for module.preZip function, which is useful for the subtemplate and the meta module.

After upgrading to 3.51.0, if you use any of the paid modules, please also run the upgrade for all your modules with this command :

npm install docxtemplater && npx -y update-docxtemplater && npm install

Update moduleApiVersion to 3.41.0.

v3.50.0

Compare Source

In the continuity of the "evaluateIdentifier" feature added in 3.49.0, we added the setIdentifier option for the expressions.js file :

This is useful if you want to do assignments in your template, like this :

{$$globalVar = 3}

You can then write :

const expressionParser = require("docxtemplater/expressions.js");

const globalData = {};
const doc = new Docxtemplater(zip, {
  parser: expressionParser.configure({
    setIdentifier(tag, value) {
      const matchGlobal = /^\$\$/g;
      if (matchGlobal.test(tag)) {
        globalData[tag] = value;
        return true;
      }
    },
    evaluateIdentifier(tag) {
      const matchGlobal = /^\$\$/g;
      if (matchGlobal.test(tag)) {
        return globalData[tag];
      }
    },
  }),
});

doc.render(/* data */);

In this case, all of your assignments to variable that start with "$$" will be assigned to the "globalData" object.

Also tags that contain one assignment and then a statement will now return the statement.

So for example, you can write :

Hello { $$admin=user; $$admin }

In this case, it will render "Hello John" (if the data is {user: "John"})

v3.49.2

Compare Source

Bugfix corruption that could appear when using the vertical loop module.

Previously, the vertical loop module could sometimes produce empty tables that would not be cleaned.

For example, with following template :

v3.49.1

Compare Source

Add doc.keepStyles and doc.includeSections to Typescript definition.

v3.49.0

Compare Source

Add possibility, when using the angular parser, to use "magic" keys to return some specific values. (This feature cannot be implemented if you use the "docxtemplater/expressions-ie11.js" package).

In your template, if you write :

{#loop}
{__val}
{/}

This will retrieve the "val" value from the scope that is above the current scope (it retrieves the value of "val" in the scope outside of the loop).

const expressionParser = require("docxtemplater/expressions.js");
const doc = new Docxtemplater(zip, {
  parser: expressionParser.configure({
    evaluateIdentifier(tag, scope, scopeList, context) {
      const matchesParent = /^(_{2,})(.*)/g;
      if (matchesParent.test(tag)) {
        const parentCount = tag.replace(matchesParent, "$1").length - 1;
        tag = tag.replace(matchesParent, "$2");
        if (parentCount >= 1) {
          for (let i = scopeList.length - 1 - parentCount; i >= 0; i--) {
            const s = scopeList[i];
            if (s[tag] != null) {
              const property = s[tag];
              return typeof property === "function"
                ? property.bind(s)
                : property;
            }
          }
        }
      }
    },
  }),
});

doc.render({
  loop: [
    {
      val: "This value",
    },
  ],
  val: "Other value", // <= This value will be retrieved
});

v3.48.0

Compare Source

Allow to configure the behavior of the "change delimiter syntax".

As documented here :

https://docxtemplater.com/docs/tag-types/#set-delimiter

You can for example use :

{=[[ ]]=}
[[name]]

It is possible to change the special behavior that will catch tags that start with a "=".

It is either possible to set the syntax.changeDelimiterPrefix to null so that it won't be possible to change the delimiters inside the template, or you can change the char that is used.

For example :

const doc = new Docxtemplater(zip, {
  syntax: {
    changeDelimiterPrefix: null,
  },
});

or

const doc = new Docxtemplater(zip, {
  syntax: {
    changeDelimiterPrefix: "$",
  },
});

v3.47.4

Compare Source

Add correct typescript typings for isIdentifierStart and isIdentifierContinue.

v3.47.3

Compare Source

Improve getStructuredTags and getTags of the inspectModule to allow to get tags present in image attributes.

(This is to work together with the image-module 3.28.0)

v3.47.2

Compare Source

Bugfix internal api mechanism :

It internally allows to have multiple traits.expandToOne().

Fixes bugs with the subtemplate and subsection module.

Update moduleApiVersion to 3.40.0.

v3.47.1

Compare Source

If zip file is not a docx file, show the following error message now :

The filetype for this file could not be identified, is this file corrupted ? Zip file contains : world.txt,xxx.log

In previous versions, the following message was shown :

The filetype for this file could not be identified, is this file corrupted ?

v3.47.0

Compare Source

Make it possible to dynamically allow to use a given tag for a module.

For example, you can write :

const doc = new Docxtemplater(zip, {
  modules: [
    {
      optionsTransformer(options, doc) {
        for (module of doc.modules) {
          if (module.name === "RawXmlModule") {
            module.prefix = function (placeholderContent) {
              if (placeholderContent === "raw") {
                return "raw";
              }
              if (placeholderContent[0] === "@&#8203;") {
                return placeholderContent.substr(1);
              }
            };
          }
        }
        return options;
      },
    },
  ],
});

This code means that if you write : {raw} in your document (without the "@​" prefix), that tag will be used as a rawxml tag.

v3.46.2

Compare Source

Add "synced-zip" event that is run right after the zip is prepared.

Update moduleApiVersion to version 3.39.0, which is used by the latest subtemplate module.

v3.46.1

Compare Source

Fix typescript issue with TxtTemplater

v3.46.0

Compare Source

When using a loop inside a powerpoint table, if the result is an empty table, correctly drop the table from the presentation.

v3.45.1

Compare Source

Add getObjectIdentifiers to expressionParser, which can be used like this :

const expressionParser = require("docxtemplater/expressions.js");
expressionParser("a.b.c").getObjectIdentifiers();
// returns { a: { b: { c: {} } } }

v3.45.0

Compare Source

Bugfix for proofstate module : Following error was thrown when using this module :

Unnamed module

Now the module should work correctly

v3.44.0

Compare Source

Make it possible to configure the angular parser for just one docxtemplater instance.

(This needs angular-expressions version 1.2.0)

Use following code :

const expressionParser = require("docxtemplater/expressions.js");
new Docxtemplater(zip, {
  parser: expressionParser.configure({
    csp: true, // this disables the use of "new Function", useful for Vercel, Deno, ...
    filters: {
      uppercase: (input) => {
        if (typeof input === "string") {
          return input.toUpperCase();
        }
        return input;
      },
    },
  }),
});

v3.43.1

Compare Source

Improve Typescript support to use the NodeNext moduleResolution setting.

See the explanation here.

Fixed in this pull request thanks to @​benasher44.

v3.43.0

Compare Source

Add getResolvedId calculation in docxtemplater to all template parts so that
all modules can store a value for each templated part. This value is guaranteed
to be the same for a given {placeholder} and data attribute between resolve
and render.

v3.42.7

Compare Source

Throw specific error if two modules with the same name are attached.

Bugfix issue on TxtTemplater when using {paragraphLoop: true}.

v3.42.6

Compare Source

Bugfix of internal API change, which was published in v3.42.5

v3.42.5

Compare Source

Bugfix for TxtTemplating :

const TxtTemplater = require("docxtemplater/text.js");

The following template :

<p>Foobar</p>

Would be rendered as :

<p&gt;Foobar</p&gt;

Also, errors such as unclosed loops, like in :

{#users}Foo

would produce an internal stacktrace.

Now, a MultiError is thrown which contains the list of all errors inside error.properties.errors

v3.42.4

Compare Source

Avoid issue Cannot read properties of undefined (reading 'length') when using renderAsync.

Now, the correct error message should be shown.

v3.42.3

Compare Source

Bugfix to avoid following error when runnig iModule.getStructuredTags() :

TypeError: Cannot read properties of undefined (reading 'replace')

Now, the tags are correctly returned.

v3.42.2

Compare Source

Bugfix to add clone method to the assertion module and to the inspect module

v3.42.1

Compare Source

Bugfix for inspect module when used together with qrcode/xlsx or table module, in some specific cases, the getTags function would return values correctly, but also return a key named "undefined", like this :

const tags = iModule.getAllTags();
console.log(tags); // would return : { name: {}, undefined: {}}

In order to apply the fix, you have to update the following modules (if you use them) :

  • qrcode module to 3.4.7
  • table module to 3.19.9
  • xlsx module to 3.14.2

v3.42.0

Compare Source

[Internal] Add filePath to each "inspect" call, which fixes a bug with the chart module when used together with the "getTags" feature of the inspect module.

If you update to this version, it is important that you also upgrade following modules if you use them :

  • slides module to version 3.5.3
  • pptx-sub module to version 3.1.4

v3.41.0

Compare Source

Correctly show error in a multi error if the scope parser execution fails inside the render function

Previously, following error was thrown :

Error: Scope parser execution failed
   at new XTScopeParserError (....)

with following template :

{#users | sortBy:'foo'}
Foo
{/}
expressionParser.filters.sortBy = function (input, ...fields) {
    if (!input) return input;
    return sortBy(input, fields);
};

(when sortBy is not imported correctly).

Now, the error will show a multierror with the list of errors that are happening + the tags that are causing the error.

Add support for angularExpressions.compile(), angularExpressions.Parser, and expressionParser.Lexer

v3.40.3

Compare Source

Fix issue when having {tag} inside title in pptx (or docx) and using the linebreak option.

v3.40.2

Compare Source

Bugfix to not add "w:sdt" inside "w:sdtContent".

Fixes a corruption on a particular type of document.

v3.40.1

Compare Source

Bugfix when using docxtemplater asynchronously, and having some module inside a loop.

The "contentType" and some other properties were not transfered correctly to the elements inside the loop.

This specifically caused an issue in the HTML module to return the correct pageHeight inside the getSize and getImage function.

This could also lead to some other bugs that were happening only when having some specific tag present in the loop.

v3.40.0

Compare Source

  • In previous versions the following code will throw an error:

    new Docxtemplater(zip, {
      paragraphLoop: true,
      linebreaks: true,
      delimiters: {
        start: "$(",
        end: ")",
      },
    });
    $(last_name) $(first_name)
    
    Some text (Some text)  Some text
    
    $(last_name) $(first_name)
    
    
    MultiError
    {
      name: "TemplateError",
      id: "unopened_tag",
      explanation: "The tag beginning with \") Some text\" is unopened"
    }

    The syntax can now be made more lenient to permit closing tags even when there are no corresponding opening tags. In your code, write :

    new Docxtemplater(zip, {
      paragraphLoop: true,
      linebreaks: true,
    
      syntax: {
        allowUnopenedTag: true,
      },
    });

    For now, the only available property for syntax object is allowUnopenedTag (it makes it possible to use the end delimiter tag as a text and not to parse it as a closing tag and cause syntax error). Fixes https://github.com/open-xml-templating/docxtemplater/issues/726.

    The default behavior for the parser without setting the syntax option is the same as in 3.39.2, meaning without the syntax.allowUnopenedTag: true option, placeholders that are closed but not opened will throw an error.

  • Internal: Refactor getDelimiterErrors function to be cleaner and more performant

  • Internal: Add tests for new functionality

v3.39.2

Compare Source

  • Internal: Remove mergeObjects from doc-utils.js
  • Internal: Small refactoring in regex
  • Internal: Avoid calling dropUnsupportedFileTypesModules too many times

v3.39.1

Compare Source

Always add {tag} in second argument to parser, like this :

parser(tag, options) {
    console.log(options.tag.module); // for image tag, it will log "open-xml-templating/docxtemplater-image-module"
}

v3.39.0

Compare Source

Add preResolve API for modules that allows to run some code before the calls to resolve.

Update moduleApiVersion to version 3.37.0

v3.38.0

Compare Source

Add support for templating content which is in comments.

v3.37.14

Compare Source

Bugfix following error, when calling setOptions and then getFullText :

Cannot read properties of null (reading 'tagsXmlTextArray')
    at XmlTemplater.getFullText (es6/xml-templater.js:53:56)
    at Docxtemplater.getFullText (es6/docxtemplater.js:484:5)

v3.37.13

Compare Source

In powerpoint, the inspect module will now return correctly for the getAllTags and getStructuredTags methods :

For this to work, you need to install version 3.4.10 of slides module or above.

For following template with the slides module attached :

{:loop}
{$index}{name}

The output of inspectModule.getAllTags() will now be :

{
    loop: {
        $index: {},
        name: {},
    },
}

v3.37.12

Compare Source

For the following template

Hi {#products}{# .  }-{ . }-{/}{/}

This did not work correctly with following data with expressions parser :

doc.render({
  products: [
    [1, 2, 3, 4],
    [4, 5, 6, 7],
  ],
});

It rendered :

Hi -1,2,3,4--4,5,6,7-

(which is incorrect)

This is because the docxtemplater/expressions.js parser was returning an object instead of the array in this case.

v3.37.11

Compare Source

Update handling of "." in angular parser.

Docxtemplater now supports the following expression :

{ . | myFilter }

This is the same as :

{ this | myFilter }

Also, the following will also work now to access the "user-name" property of the root object (synonym of this["user-name"] :

{.["user-name"]}

v3.37.10

Compare Source

Important bugfix for modules, if you are still using the legacy constructor (eg if you still have attachModule somewhere in your code.

For example, one issue that could happen is with the HTML module, you could have following stacktrace :

Cannot read property 'getElementsByTagName' of undefined` error

This would happen when adding lists, and only if you're using one of following methods : attachModule, setOptions, or loadZip.

v3.37.9

Compare Source

Update to render parts of the documents in the most natural order :

First all header parts, than the main document body, than the footer part.

v3.37.8

Compare Source

When using the following code :

const expressionParser = require("docxtemplater/expressions.js");
const doc = new Docxtemplater(zip, { parser: expressionParser });
doc.render();

This would always fail (when the scope was not set), but this should be allowed.

This will now work correctly.

v3.37.7

Compare Source

Correctly calculate the endLindex for loop module.

This fixes a bug of the Segmentmodule (part of the subtemplate module) where the segment would show wrongly an error of "Unclosed loop" when using the segment module with following template :

{:segment s}
{#loop}{#loop}{value} {/}{/}
{:segment/}
{#loop}
{:includesegment s}
{/}

This fix also needs the latest subtemplate module : version 3.12.3

v3.37.6

Compare Source

Template docProps/app.xml before word/document.xml.

This way, users can write assignments in the word/settings.xml, and
use the exposed variables in the word/document.xml

With 3.37.5, require("docxtemplater/text") would throw the following error :

Cannot find module './lexer.js' from 'node_modules/docxtemplater/text.js'

This is now fixed in version 3.37.6

v3.37.5

Compare Source

The TxtTemplater feature is now available using require("docxtemplater/text")

const TxtTemplater = require("docxtemplater/text.js");
const doc = new TxtTemplater("Hello {user}, how are you ?");
const result = doc.render({ user: "John" });
console.log(result); // Shows : "Hello John, how are you ?"

Previously this was only available at "docxtemplater/js/text.js", but now both are supported.

v3.37.4

Compare Source

Add typings definitions for docxtemplater/js/text.js (Fixes #​715)

v3.37.3

Compare Source

Add better typings to expressions.js (including typings for filters).

v3.37.2

Compare Source

Add support to get identifiers when using the docxtemplater/expressions.js package :

const expressionParser = require("docxtemplater/expressions.js");
const identifiers = expressionParser("x+0+users").getIdentifiers();
// identifiers will be : ["x", "users"]

v3.37.1

Compare Source

Bugfix following error, when calling setOptions and then getFullText :

Cannot read properties of null (reading 'tagsXmlTextArray')
    at XmlTemplater.getFullText (es6/xml-templater.js:53:56)
    at Docxtemplater.getFullText (es6/docxtemplater.js:484:5)

v3.37.0

Compare Source

Improve the way {$index} is handled with the expressions parser.

Previously, if you wrote the following :

{#todos}
{#important}{$index}.! {text}{/}
{^important}{$index}. ({text}){/}
{/}

The $index value would always be equal to 0.

This was because the $index would use the closest condition or loop.

Now, the library will look whether the {#important} is using an array or a boolean. Only for arrays will it calculate the {$index}, it will ignore any section that is a condition.

This means that the output of the following will correctly be :

0.! Do the dishes
1.! Invite XYZ 2. (Other thing)

Previously, the same template would show just 0 for the index.

v3.36.1

Compare Source

Bugfix when using following in the template :

{this["first name"]}

With following file :

doc.render({
  "first name": "John",
});

This was incorrectly rendering undefined.

The bug was present since version 3.32.0

Version 3.31.6 and before were not affected by this bug.

Now, the code will correctly render : "John" in this case

v3.36.0

Compare Source

Bugfix issue #​707 : Correctly handle usage of {#.}{.}{/} with angular parser

v3.35.1

Compare Source

v3.35.0

Compare Source

Update moduleApiVersion to version 3.36.0

  • Now the modules that define their supportedFileTypes will correctly be removed if the filetype does'nt match even when using the attachModule API.

  • Bugfix in FixDocPRCorruptionModule : when using the following code :

    const fixDocPrCorruption = require("docxtemplater/js/modules/fix-doc-pr-corruption.js");
    const doc = new Docxtemplater(zip, { modules: [fixDocPrCorruption] });

    The issue was that if you attached the same module to multiple docxtemplater instances in parallel, because of badly handled state, the state for the fixDocPrCorruption was overwritten

    const doc1 = new Docxtemplater(zip, { modules: [fixDocPrCorruption] });
    const doc2 = new Docxtemplater(zip, { modules: [fixDocPrCorruption] });
    doc1.render(); // In this situation, the fixDocPrCorruption would use data from the doc2, which is incorrect, and could result in a corrupt document

    Now, the fixDocPrCorruption can be used on multiple docxtemplater instances without causing any issue.

v3.34.3

Compare Source

Fix typescript definition for constructor / zip instance.

Allows to correctly autocomplete after doing doc.getZip().generate()

Thanks to @​oleksandr-danylchenko https://github.com/open-xml-templating/docxtemplater/pull/704

v3.34.2

Compare Source

Fix typescript definition for getAllStructuredTags : remove file argument.

Fixed in #​702 thanks to @​oleksandr-danylchenko

v3.34.1

Compare Source

Bugfix in require("docxtemplater/expressions.js") :

Avoid error const expressionParser = require("docxtemplater/expressions.js");

TypeError: 'set' on proxy: trap returned falsish for property 'x'

This will no more happen now, in the case where for example you wanted to set a property to any falsy value, like this :

{x=0}

v3.34.0

Compare Source

Add support to reorder modules automatically using module.priority.

Fetch data from _rels/.rels and pass it to each module function using the relType attribute.

Fixes issue in HTML module for some particular input that contains some tp/document-orig.xml file.

v3.33.0

[Compare Source](https://redirect.github.com/open-xml-templating/docxtemplater/compare/v3.32.6...v3.


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from e8958da to 89afd37 Compare March 27, 2020 15:40
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.17.2 fix(deps): update dependency docxtemplater to v3.17.3 Mar 27, 2020
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from 89afd37 to c837918 Compare April 2, 2020 21:53
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.17.3 fix(deps): update dependency docxtemplater to v3.17.4 Apr 2, 2020
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from c837918 to cdee1de Compare April 3, 2020 21:36
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.17.4 fix(deps): update dependency docxtemplater to v3.17.5 Apr 3, 2020
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from cdee1de to 3c4aa85 Compare April 17, 2020 14:54
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.17.5 fix(deps): update dependency docxtemplater to v3.17.6 Apr 17, 2020
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from 3c4aa85 to d9e1bce Compare June 15, 2020 14:42
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.17.6 fix(deps): update dependency docxtemplater to v3.17.7 Jun 15, 2020
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.17.7 fix(deps): update dependency docxtemplater to v3.17.8 Jun 15, 2020
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch 2 times, most recently from c884f17 to 5e8f15a Compare June 18, 2020 13:04
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.17.8 fix(deps): update dependency docxtemplater to v3.17.9 Jun 18, 2020
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from 5e8f15a to 324d74f Compare August 22, 2020 05:57
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.17.9 fix(deps): update dependency docxtemplater to v3.18.0 Aug 22, 2020
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from 324d74f to 67bdb6a Compare October 28, 2020 05:55
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.18.0 fix(deps): update dependency docxtemplater to v3.19.6 Oct 28, 2020
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from 67bdb6a to 3cb7bf0 Compare November 5, 2020 22:57
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.19.6 fix(deps): update dependency docxtemplater to v3.19.7 Nov 5, 2020
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from 3cb7bf0 to cb724e7 Compare January 22, 2021 11:53
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.19.7 fix(deps): update dependency docxtemplater to v3.19.9 Jan 22, 2021
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from cb724e7 to 4a4f78b Compare February 9, 2021 13:00
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.19.9 fix(deps): update dependency docxtemplater to v3.19.10 Feb 9, 2021
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from 4a4f78b to 757b08a Compare April 26, 2021 15:27
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.19.10 fix(deps): update dependency docxtemplater to v3.21.1 Apr 26, 2021
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from 757b08a to f9435fd Compare May 20, 2021 10:29
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.21.1 fix(deps): update dependency docxtemplater to v3.21.2 May 20, 2021
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.60.1 fix(deps): update dependency docxtemplater to v3.60.2 Mar 22, 2025
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from 7ce5176 to 458dfbd Compare April 3, 2025 15:42
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.60.2 fix(deps): update dependency docxtemplater to v3.61.0 Apr 3, 2025
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from 458dfbd to b616f00 Compare April 13, 2025 11:06
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.61.0 fix(deps): update dependency docxtemplater to v3.61.1 Apr 13, 2025
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from b616f00 to 4a4a611 Compare May 10, 2025 22:33
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.61.1 fix(deps): update dependency docxtemplater to v3.61.2 May 10, 2025
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from 4a4a611 to 955a83f Compare May 14, 2025 20:19
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.61.2 fix(deps): update dependency docxtemplater to v3.62.0 May 14, 2025
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from 955a83f to 1260430 Compare May 15, 2025 17:29
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.62.0 fix(deps): update dependency docxtemplater to v3.62.1 May 15, 2025
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from 1260430 to 418e12a Compare May 15, 2025 23:45
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.62.1 fix(deps): update dependency docxtemplater to v3.62.2 May 15, 2025
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from 418e12a to 1b291d9 Compare May 22, 2025 12:56
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.62.2 fix(deps): update dependency docxtemplater to v3.63.0 May 22, 2025
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from 1b291d9 to fb4e373 Compare May 29, 2025 22:58
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.63.0 fix(deps): update dependency docxtemplater to v3.63.2 May 29, 2025
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from fb4e373 to 93d6a8d Compare June 15, 2025 08:16
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.63.2 fix(deps): update dependency docxtemplater to v3.63.3 Jun 15, 2025
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from 93d6a8d to cdcf334 Compare June 17, 2025 20:36
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.63.3 fix(deps): update dependency docxtemplater to v3.63.4 Jun 17, 2025
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from cdcf334 to be90a05 Compare June 19, 2025 21:58
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.63.4 fix(deps): update dependency docxtemplater to v3.64.0 Jun 19, 2025
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from be90a05 to bda70c8 Compare June 20, 2025 03:14
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.64.0 fix(deps): update dependency docxtemplater to v3.65.0 Jun 20, 2025
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from bda70c8 to 179fa99 Compare June 25, 2025 23:56
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.65.0 fix(deps): update dependency docxtemplater to v3.65.1 Jun 25, 2025
@renovate renovate bot force-pushed the renovate/docxtemplater-3.x branch from 179fa99 to a7e9f73 Compare July 11, 2025 11:10
@renovate renovate bot changed the title fix(deps): update dependency docxtemplater to v3.65.1 fix(deps): update dependency docxtemplater to v3.65.2 Jul 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant