Sha256: 8e136b04fc90c30091231e2b79e56c54600dfc4cc4b66275618d553df3f5f778

Contents?: true

Size: 598 Bytes

Versions: 69

Compression:

Stored size: 598 Bytes

Contents

var mout = require('mout');
var leadLinesRegExp = /^\r?\n/;
var multipleLinesRegExp = /\r?\n(\r?\n)+/mg;

function condense(Handlebars) {
    Handlebars.registerHelper('condense', function (context) {
        var str = context.fn(this);

        // Remove multiple lines
        str = str.replace(multipleLinesRegExp, '$1');

        // Remove leading new lines (while keeping indentation)
        str = str.replace(leadLinesRegExp, '');

        // Remove trailing whitespaces (including new lines);
        str = mout.string.rtrim(str);

        return str;
    });
}

module.exports = condense;

Version data entries

69 entries across 69 versions & 2 rubygems

Version Path
trusty-festivity-extension-2.6.3 node_modules/bower/templates/helpers/condense.js
trusty-festivity-extension-2.6.2 node_modules/bower/templates/helpers/condense.js
trusty-festivity-extension-2.6.1 node_modules/bower/templates/helpers/condense.js
trusty-festivity-extension-2.6 node_modules/bower/templates/helpers/condense.js
trusty-festivity-extension-2.5.19 node_modules/bower/templates/helpers/condense.js
trusty-festivity-extension-2.5.18 node_modules/bower/templates/helpers/condense.js
trusty-festivity-extension-2.5.17 node_modules/bower/templates/helpers/condense.js
trusty-festivity-extension-2.5.16 node_modules/bower/templates/helpers/condense.js
trusty-festivity-extension-2.5.15 node_modules/bower/templates/helpers/condense.js
trusty-festivity-extension-2.5.14 node_modules/bower/templates/helpers/condense.js
trusty-festivity-extension-2.5.13 node_modules/bower/templates/helpers/condense.js
trusty-festivity-extension-2.5.12 node_modules/bower/templates/helpers/condense.js
trusty-festivity-extension-2.5.11 node_modules/bower/templates/helpers/condense.js
trusty-festivity-extension-2.5.10 node_modules/bower/templates/helpers/condense.js
trusty-festivity-extension-2.5.9 node_modules/bower/templates/helpers/condense.js
trusty-festivity-extension-2.5.8 node_modules/bower/templates/helpers/condense.js
trusty-festivity-extension-2.5.7 node_modules/bower/templates/helpers/condense.js
trusty-festivity-extension-2.5.6 node_modules/bower/templates/helpers/condense.js
trusty-festivity-extension-2.5.5 node_modules/bower/templates/helpers/condense.js
trusty-festivity-extension-2.5.4 node_modules/bower/templates/helpers/condense.js