posthtml-nunjucks

0.1.2 • Public • Published
PostHTML

PostHTML Nunjucks Plugin

A PostHTML plugin wrapping Nunjucks library.

npm GitHub Publish codecov

About

This is a PostHTML plugin that wraps Nunjucks library.

Introduction

This plugin applies a Nunjucks temple to the file being processed:

Input:

<div filter="uppercase">{{ name }}</div>

Output:

<div>TEST NAME</div>

Install

$ npm i posthtml posthtml-nunjucks

Usage

A simple plugin usage would be:

const posthtml = require('posthtml');
const nunjucks = require('posthtml-nunjucks');

posthtml([nunjucks({ context: { name: 'TEST NAME' } })])
    .process('<div>{{ name }}</div>')
    .then((result) => console.log(result.html));

// <div>TEST NAME</div>

Options

The options accepted for the plugin are:

config

Type: object
Default: {}

Configuration to be passed to nunjucks as specified here.

context

Type: object
Default: {}

Context to be passed to the templates to be applied, as specified here.

Dependents (0)

Package Sidebar

Install

npm i posthtml-nunjucks

Weekly Downloads

2

Version

0.1.2

License

MIT

Unpacked Size

8.96 kB

Total Files

11

Last publish

Collaborators

  • gguridi