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

jbmoelker/nunjucks-tag-spaceless

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nunjucks tag spaceless

nunjucks-tag-spaceless on npm Build Status Coverage 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

About

Nunjucks tag to remove whitespace between HTML tags.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors