Extending a template engine

If you need to extend your template engine, you can do that by requiring it in your config file via engine.instance and passing it to miyagi.

This is an example for twig:

const twig = require("twig");

twig.extendFunction("customFunction", function customFunction() { ... });

module.exports = {
  ...
  engine: {
    instance: twig.twig,
  },
  ...
}

If you are using the twig-drupal or twig-laravel extension, you need to extend twig like this:

const twig = require("twig");

module.exports = {
  ...
  engine: {
    instance: twig.twig,
  },
  extensions: [
    [
      twigDrupal,
      {
        init(twig) {
          twig.extendFunction("customFunction", function customFunction() { ... });
        },
      },
    ],
  ],
  ...
}