Comparing version 0.5.4 to 0.5.5
28
beard.js
@@ -26,12 +26,12 @@ const fs = require('fs'); | ||
compiled(path, context) { | ||
context.path = resolvePath(path, context.path); | ||
compiled(path, parentPath = '') { | ||
path = resolvePath(path, parentPath); | ||
if (this.opts.cache) { | ||
const str = this.opts.templates[context.path]; | ||
const key = hash(context.path); | ||
if (!this.fnCache[key]) this.fnCache[key] = compile(str, context.path); | ||
const str = this.opts.templates[path]; | ||
const key = hash(path); | ||
if (!this.fnCache[key]) this.fnCache[key] = compile(str, path); | ||
return this.fnCache[key]; | ||
} else { | ||
const str = fs.readFileSync(this.pathMap[context.path], 'utf8'); | ||
return compile(str, context.path); | ||
const str = fs.readFileSync(this.pathMap[path], 'utf8'); | ||
return compile(str, path); | ||
} | ||
@@ -50,6 +50,5 @@ } | ||
compiled: this.compiled.bind(this), | ||
asset: this.asset.bind(this), | ||
path: '' | ||
asset: this.asset.bind(this) | ||
} | ||
return this.compiled(path, context)(context); | ||
return this.compiled(path)(context); | ||
} | ||
@@ -104,3 +103,3 @@ } | ||
blockEnd: () => 'eval(`var ${_blockName} = _blockCapture`); _context.globals[_blockName] = _blockCapture; _blockName = null;', | ||
asset: (_, path) => `_capture(_context.asset("${path}", _context.path));`, | ||
asset: (_, path) => `_capture(_context.asset("${path}", _currentPath));`, | ||
put: (_, varname) => `_capture(typeof ${varname} !== "undefined" ? ${varname} : "");`, | ||
@@ -118,3 +117,3 @@ exists: (_, varname) => `if (typeof ${varname} !== "undefined") {`, | ||
_context.locals.push(Object.assign(_context.locals[_context.locals.length - 1], ${data})); | ||
_capture(_context.compiled("${includePath}", _context)(_context)); | ||
_capture(_context.compiled("${includePath}", _currentPath)(_context)); | ||
_context.locals.pop(); | ||
@@ -149,3 +148,3 @@ `; | ||
function compile(str, context) { | ||
function compile(str, path) { | ||
let layout = ''; | ||
@@ -157,3 +156,3 @@ | ||
_context.globals.view = _buffer; | ||
_buffer = _context.compiled('${path}', _context)(_context); | ||
_buffer = _context.compiled('${path}', _currentPath)(_context); | ||
`; | ||
@@ -166,2 +165,3 @@ return ''; | ||
const fn = ` | ||
var _currentPath = '${path}'; | ||
var _buffer = ''; | ||
@@ -168,0 +168,0 @@ var _blockName; |
{ | ||
"name": "beard", | ||
"version": "0.5.4", | ||
"version": "0.5.5", | ||
"description": "More than a mustache.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14344