Socket
Socket
Sign inDemoInstall

beard

Package Overview
Dependencies
1
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.9 to 0.6.0

108

beard.js

@@ -36,4 +36,11 @@ const fs = require('fs');

if (this.opts.customTags) {
exps.customTag = new RegExp('^(' + Object.keys(this.opts.customTags).join('|') + ")\\\s+([\\\s\\\S]+)$");
exps.customTag = new RegExp('^(' + Object.keys(this.opts.customTags).join('|') + ")\\\s+([^,]+)(,\\\s*((?!(,\\\s*content)|(content\\\s*$))[\\\s\\\S])*)?$");
}
if (this.opts.customContentTags) {
exps.customContentTag = new RegExp('^(' + Object.keys(this.opts.customContentTags).join('|') + ")\\\s+([^,]+)(,\\\s*((?!(,\\\s*content)|(content\\\s*$))[\\\s\\\S])*)?,\\\s*content$");
exps.endCustomTag = new RegExp('^end(' + Object.keys(this.opts.customContentTags).join('|') + ')$');
} else {
this.opts.customContentTags = {};
}
}

@@ -56,7 +63,14 @@

const resolvedPath = resolvePath(path, parentPath);
if (this.opts.customContentTags.hasOwnProperty(name)) return this.opts.customContentTags[name](resolvedPath, data);
return this.opts.customTags[name](resolvedPath, data);
}
customContentTag(name, parentPath, path, data, content) {
data.content = content;
const resolvedPath = resolvePath(path, parentPath);
return this.opts.customContentTags[name](resolvedPath, data);
}
include(context, parentPath, path, data = {}) {
context.locals.push(Object.assign(context.locals[context.locals.length - 1], data));
context.locals.push(data);
const result = context.compiled(path, parentPath)(context);

@@ -73,3 +87,4 @@ context.locals.pop();

include: this.include.bind(this),
customTag: this.customTag.bind(this)
customTag: this.customTag.bind(this),
customContentTag: this.customContentTag.bind(this)
}

@@ -96,25 +111,30 @@ return this.compiled(path)(context);

const tags = [
'include', 'block', 'blockEnd',
'put', 'encode', 'comment', 'if',
'exists', 'elseIf', 'else', 'for',
'each', 'end', 'extends', 'customTag'
'include', 'includeContent', 'endInclude',
'block', 'blockEnd', 'put', 'encode',
'comment', 'if', 'exists', 'elseIf',
'else', 'for', 'each', 'end', 'extends',
'customTag', 'customContentTag', 'endCustomTag'
];
const exps = {
extends: (/^extends\s(.+)$/g),
include: (/^include\s([\s\S]+)$/m),
put: (/^put\s+(.+)$/),
exists: (/^exists\s+(.+)$/),
block: (/^block\s+(.[^}]*)/),
blockEnd: (/^endblock$/),
encode: (/^\:(.*)/),
comment: (/^\*.*\*$/),
statement: (/{{\s*([\S\s(?!}})]+?)\s*}}(?!\})/g),
if: (/^if\s+([^]*)$/),
elseIf: (/^else\s+if\s+([^]*)$/),
else: (/^else$/),
for: (/^for\s+([$A-Za-z_][0-9A-Za-z_]*)(?:\s*,\s*([$A-Za-z_][0-9A-Za-z_]*))?\s+in\s+(.*)$/),
each: (/^each\s+([$A-Za-z_][0-9A-Za-z_]*)(?:\s*,\s*([$A-Za-z_][0-9A-Za-z_]*))?\s+in\s(.*)$/),
end: (/^end$/),
customTag: (/^(?!)$/)
extends: (/^extends\s(.+)$/g),
include: (/^include\s+([^,]+)(,\s*((?!(,\s*content)|(content\s*$))[\s\S])*)?$/),
includeContent: (/^include\s+([^,]+)(,\s*((?!(,\s*content)|(content\s*$))[\s\S])*)?,\s*content$/),
endInclude: (/^endinclude$/),
put: (/^put\s+(.+)$/),
exists: (/^exists\s+(.+)$/),
block: (/^block\s+(.[^}]*)/),
blockEnd: (/^endblock$/),
encode: (/^\:(.*)/),
comment: (/^\*.*\*$/),
statement: (/{{\s*([\S\s(?!}})]+?)\s*}}(?!\})/g),
if: (/^if\s+([^]*)$/),
elseIf: (/^else\s+if\s+([^]*)$/),
else: (/^else$/),
for: (/^for\s+([$A-Za-z_][0-9A-Za-z_]*)(?:\s*,\s*([$A-Za-z_][0-9A-Za-z_]*))?\s+in\s+(.*)$/),
each: (/^each\s+([$A-Za-z_][0-9A-Za-z_]*)(?:\s*,\s*([$A-Za-z_][0-9A-Za-z_]*))?\s+in\s(.*)$/),
end: (/^end$/),
customTag: (/^(?!)$/),
customContentTag: (/^(?!)$/),
endCustomTag: (/^(?!)$/)
};

@@ -136,15 +156,19 @@

const parse = {
extends: (_, path) => ` _context.globals.content = _buffer; _buffer = _context.compiled(${path}, _currentPath)(_context);`,
block: (_, blockname) => `_blockNames.push("${blockname}"); _blockCaptures.push('');`,
blockEnd: () => 'eval(`var ${_blockNames[_blockNames.length - 1]} = _blockCaptures[_blockCaptures.length - 1]`); _context.globals[_blockNames[_blockNames.length - 1]] = _blockCaptures[_blockCaptures.length - 1]; _blockNames.pop(); _blockCaptures.pop();',
put: (_, varname) => `_capture(typeof ${varname} !== "undefined" ? ${varname} : "");`,
exists: (_, varname) => `if (typeof ${varname} !== "undefined") {`,
encode: (_, statement) => `_encode(${statement});`,
comment: () => '',
if: (_, statement) => `if (${statement}) {`,
elseIf: (_, statement) => `} else if (${statement}) {`,
else: () => '} else {',
end: () => '}',
customTag: (_, name, args) => `_capture(_context.customTag("${name}", _currentPath, ${args}));`,
include: (_, args) => `_capture(_context.include(_context, _currentPath, ${args}));`,
extends: (_, path) => ` _context.globals.content = _buffer; _buffer = _context.compiled(${path}, _currentPath)(_context);`,
block: (_, blockname) => `_blockNames.push("${blockname}"); _blockCaptures.push('');`,
blockEnd: () => 'eval(`var ${_blockNames[_blockNames.length - 1]} = _blockCaptures[_blockCaptures.length - 1]`); _context.globals[_blockNames[_blockNames.length - 1]] = _blockCaptures[_blockCaptures.length - 1]; _blockNames.pop(); _blockCaptures.pop();',
put: (_, varname) => `_capture(typeof ${varname} !== "undefined" ? ${varname} : "");`,
exists: (_, varname) => `if (typeof ${varname} !== "undefined") {`,
encode: (_, statement) => `_encode(${statement});`,
comment: () => '',
if: (_, statement) => `if (${statement}) {`,
elseIf: (_, statement) => `} else if (${statement}) {`,
else: () => '} else {',
end: () => '}',
customTag: (_, name, path, args) => `_capture(_context.customTag("${name}", _currentPath, ${path} ${args == null ? '' : args}));`,
customContentTag: (_, name, path, args) => `_blockNames.push('content'); _blockCaptures.push(''); _capturePaths.push(${path}); _captureArgs.push(${args == null ? '{}' : args.replace(/^,/, '')});`,
endCustomTag: (_, name) => `_blockNames.pop(); _capture(_context.customContentTag("${name}", _currentPath, _capturePaths.pop(), _captureArgs.pop(), _blockCaptures.pop()));`,
include: (_, path, args) => `_capture(_context.include(_context, _currentPath, ${path} ${args == null ? '' : args}));`,
includeContent: (_, path, args) => `_blockNames.push('content'); _blockCaptures.push(''); _capturePaths.push(${path}); _captureArgs.push(${args == null ? '{}' : args.replace(/^,/, '')});`,
endInclude: () => `var __locals = _captureArgs.pop(); __locals.content = _blockCaptures.pop(); _blockNames.pop(); _capture(_context.include(_context, _currentPath, _capturePaths.pop(), __locals));`,
for: (_, value, key, objValue) => {

@@ -222,2 +246,4 @@ if (!key) key = `_iterator_${uniqueIterator(value)}`;

var _blockCaptures = [];
var _capturePaths = [];
var _captureArgs = [];

@@ -248,6 +274,8 @@ function _capture(str) {

var _locals = _context.locals[_context.locals.length - 1];
for (var prop in _locals) {
if (_locals.hasOwnProperty(prop)) {
eval('var ' + prop + ' = _locals[prop]');
for (var i = 0; i < _context.locals.length; i++) {
var _locals = _context.locals[i];
for (var prop in _locals) {
if (_locals.hasOwnProperty(prop)) {
eval('var ' + prop + ' = _locals[prop]');
}
}

@@ -254,0 +282,0 @@ }

{
"name": "beard",
"version": "0.5.9",
"version": "0.6.0",
"description": "More than a mustache.",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc