Search code examples
javascripttemplatesgruntjsnunjucks

Nunjucks precompile clean html


I use Nunjucks percompiled template and I'd like to clean the template.js output from useless spaces and linebreak.

Compiled template keeps useless space and line break from original template:

"<form>\n        <div class=\"choices\">\n            <div class=\"choice\">\n"

Custom tags like nunjucks-tag-spaceless do the regex stuff client side. There is no way to do this during compile step to save size / time ?


Solution

  • You can try to use jlto library for your purpose: https://www.npmjs.com/package/jlto