Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

docxtemplater

Package Overview
Dependencies
Maintainers
1
Versions
319
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

docxtemplater - npm Package Versions

23
32

3.52.0

Diff

Changelog

Source

3.52.0

Add syntax.allowUnclosedTag option.

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

edi9999
published 3.51.2 •

Changelog

Source

3.51.2

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
edi9999
published 3.51.1 •

Changelog

Source

3.51.1

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

edi9999
published 3.51.0 •

Changelog

Source

3.51.0

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.

edi9999
published 3.50.0 •

Changelog

Source

3.50.0

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"})

edi9999
published 3.49.2 •

Changelog

Source

3.49.2

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 :

--------------
| {:vt#loop} |
--------------
| XXX        |
| {:vt/}     |
--------------

If the loop was an empty array, the output would produce a corrupt document.

The table is now correctly removed in this case.

The table will

edi9999
published 3.49.1 •

Changelog

Source

3.49.1

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

edi9999
published 3.49.0 •

Changelog

Source

3.49.0

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
});
edi9999
published 3.48.0 •

Changelog

Source

3.48.0

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: "$",
  },
});
edi9999
published 3.47.4 •

Changelog

Source

3.47.4

Add correct typescript typings for isIdentifierStart and isIdentifierContinue.

23
32
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc