Skip to content

Commit

Permalink
Merge pull request #29 from digitalica/master
Browse files Browse the repository at this point in the history
Update dependencies to prevent audit warnings
  • Loading branch information
dciccale committed Apr 20, 2021
2 parents 87ceb35 + 7609279 commit c8bf7fb
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 14 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
@@ -1,6 +1,8 @@
sudo: false
language: node_js
node_js:
- "0.10"
- "6"
- "8"
- "10"
after_script:
- npm run coveralls
4 changes: 2 additions & 2 deletions lib/blocktypes/template.js
Expand Up @@ -5,10 +5,10 @@ var utils = require('../utils');
module.exports = template;

function template(content, block, blockLine, blockContent) {
var compiledTmpl = utils._.template(blockContent, this.data, this.options.templateSettings);
var compiledTmpl = utils._.template(blockContent, this.options.templateSettings);

// Clean template output and fix indent
compiledTmpl = block.indent + compiledTmpl.trim().replace(/(\r\n|\n)\s*/g, '$1' + block.indent);
compiledTmpl = block.indent + compiledTmpl(this.data).trim().replace(/(\r\n|\n)\s*/g, '$1' + block.indent);

return content.replace(blockLine, compiledTmpl.replace(/\$/g, '$$$'));
}
6 changes: 5 additions & 1 deletion lib/htmlprocessor.js
Expand Up @@ -117,7 +117,11 @@ HTMLProcessor.prototype.processContent = function (content, filePath) {
return content;
};

HTMLProcessor.prototype.template = utils._.template;
// Lodash 2.4 like template function
HTMLProcessor.prototype.template = function(text, data, options) {
let compiledTemplate = utils._.template(text, options);
return compiledTemplate(data);
};

// Export the processor
module.exports = HTMLProcessor;
4 changes: 2 additions & 2 deletions lib/parser.js
Expand Up @@ -99,10 +99,10 @@ Parser.prototype._writeToList = function (line, filePath) {
if (match) {
this.listFile.write(filePath + ':' + match[1] + '\n');
}
}
};

Parser.prototype._getMatch = function (line) {
var matchCss = line.match(this.cssHref);
var matchJs = line.match(this.jsSrc);
return matchCss || matchJs || null;
}
};
8 changes: 4 additions & 4 deletions lib/utils.js
Expand Up @@ -20,13 +20,13 @@ module.exports = {
_: _
};

function read(filepath, encoding) {
function read(filepath) {
return fs.readFileSync(filepath, 'utf-8');
};
}

function exists(filepath) {
return filepath && fs.existsSync(filepath);
};
}

// courtesy of grunt
function mkdir(dirpath, mode) {
Expand All @@ -47,4 +47,4 @@ function mkdir(dirpath, mode) {
}
return parts;
}, '');
};
}
8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -39,11 +39,11 @@
"optimize"
],
"dependencies": {
"lodash": "~2.4.1"
"lodash": "^4.17.11"
},
"devDependencies": {
"coveralls": "^2.11.3",
"istanbul": "^0.3.17",
"mocha": "^2.2.5"
"coveralls": "^3.0.2",
"istanbul": "^0.4.5",
"mocha": "^5.2.0"
}
}
16 changes: 16 additions & 0 deletions test/test.js
Expand Up @@ -420,3 +420,19 @@ describe('list', function () {
});
});
});

describe('lodash template', function() {
it ('should offer a lodash 2.4 compatible template function in prototype', function() {
var text = 'hello {{ name }}!';
var data = { 'name': 'mustache' };
var options = { 'interpolate': /{{([\s\S]+?)}}/g };
var processorInstance = htmlprocessor({
src: []
});
var actual = processorInstance.template(text, data, options);
// var actual = utils._.template(text, options)(data);
var expected = 'hello mustache!';

assert.equal(actual, expected);
})
});

0 comments on commit c8bf7fb

Please sign in to comment.