beard
Advanced tools
Comparing version 0.5.1 to 0.5.2
14
beard.js
@@ -13,2 +13,4 @@ const fs = require('fs'); | ||
const cleanWhitespace = str => str.replace(/\s+/g, ' ').trim(); | ||
module.exports = function(opts = {}) { | ||
@@ -27,3 +29,4 @@ opts.cache = opts.cache != undefined ? opts.cache : true; | ||
const key = path.replace(regex, ''); | ||
opts.templates[key] = fs.readFileSync(path, 'utf8'); | ||
const body = fs.readFileSync(path, 'utf8'); | ||
opts.templates[key] = opts.cache ? cleanWhitespace(body) : body; | ||
pathMap[key] = path; | ||
@@ -121,3 +124,3 @@ }); | ||
: fs.readFileSync(pathMap[fullPath], 'utf8'); | ||
let key = hash(str); | ||
const key = hash(fullPath); | ||
@@ -143,6 +146,3 @@ if (!fnCache[key]) { | ||
.replace(new RegExp('\\\\', 'g'), '\\\\').replace(/"/g, '\\"') | ||
.replace(exps.statement, parser) | ||
.replace(/\n/g, '\\n') | ||
.replace(/\t/g, '\\t') | ||
.replace(/\r/g, '\\r'); | ||
.replace(exps.statement, parser); | ||
@@ -194,3 +194,3 @@ const fn = ` | ||
try { | ||
eval(fn); | ||
eval(cleanWhitespace(fn)); | ||
return _compiledFn.bind(_compiledFn); | ||
@@ -197,0 +197,0 @@ } catch (e) { |
{ | ||
"name": "beard", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "More than a mustache.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
12528
1
231