1.0.0 • Published 7 years ago

nunjucks-tag-spaceless v1.0.0

Weekly downloads
256
License
MIT
Repository
-
Last release
7 years ago

Nunjucks tag spaceless

Build Status

Nunjucks tag to remove whitespace between HTML tags, not whitespace within HTML tags or whitespace in plain text.

This tag is based on and compatible with the Twig spaceless tag, Swig spaceless tag and Django spaceless tag.

Install

$ npm install --save nunjucks-tag-spaceless

Usage

Install as custom tag extension:

var nunjucks = require('nunjucks');
var SpacelessExtension = require('nunjucks-tag-spaceless');

var env = new nunjucks.Environment();
env.addExtension('spaceless', new SpacelessExtension());

Use in template:

{% spaceless %}

    <div>
        <strong> text </strong>
    </div>

{% endspaceless %}

Outputs <div><strong> text </strong></div>

more examples

Note: spaceless will yield unexpected results if you use custom syntax containing > and < symbols.

Support

Same support as Nunjucks:

  • Node >= v0.10
  • all modern browsers
  • IE8 requires es5-shim

License

MIT Licensed © Jasper Moelker