Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

monkberry

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

monkberry - npm Package Compare versions

Comparing version 3.6.1 to 3.7.0

.babelrc

13

lib/compiler/for.js

@@ -11,9 +11,14 @@ 'use strict';

var templateName = figure.name + '.for' + figure.uniqid('template_name');
// TODO: Optimize when child has only one custom node. Replace templateName with that custom tag name.
var templateName = undefined;
if (this.templateNames && this.templateNames.body) {
templateName = figure.name + '.' + this.templateNames.body;
} else {
templateName = figure.name + '.for' + figure.uniqid('template_name');
}
var childrenName = 'children' + figure.uniqid('child_name');
var placeholder;
var parentNode = (0, _utils.lookUpOnlyOneChild)(this);
var placeholder = undefined,
parentNode = (0, _utils.lookUpOnlyOneChild)(this);
if (parentNode) {

@@ -20,0 +25,0 @@ placeholder = parentNode.nodeName;

@@ -9,11 +9,22 @@ 'use strict';

ast.IfStatementNode.prototype.compile = function (figure) {
var templateNameForThen = figure.name + '.if' + figure.uniqid('template_name');
var templateNameForElse = templateNameForThen + '.else';
// TODO: Optimize when child has only one custom node. Replace templateName with that custom tag name.
var templateNameForThen = undefined,
templateNameForOtherwise = undefined;
if (this.templateNames && this.templateNames.then) {
templateNameForThen = figure.name + '.' + this.templateNames.then;
} else {
templateNameForThen = figure.name + '.if' + figure.uniqid('template_name');
}
if (this.templateNames && this.templateNames.otherwise) {
templateNameForOtherwise = figure.name + '.' + this.templateNames.otherwise;
} else {
templateNameForOtherwise = templateNameForThen + '.else';
}
var childNameForThen = 'child' + figure.uniqid('child_name');
var childNameForElse = 'child' + figure.uniqid('child_name');
var childNameForOtherwise = 'child' + figure.uniqid('child_name');
var placeholder;
var parentNode = (0, _utils.lookUpOnlyOneChild)(this);
var placeholder = undefined,
parentNode = (0, _utils.lookUpOnlyOneChild)(this);
if (parentNode) {

@@ -28,4 +39,4 @@ placeholder = parentNode.nodeName;

if (this._else) {
figure.declare(["var ", childNameForElse, " = {};"]);
if (this.otherwise) {
figure.declare(["var ", childNameForOtherwise, " = {};"]);
}

@@ -35,8 +46,8 @@

var variablesOfExpression = (0, _variable.collectVariables)(this.test);
var variablesOfExpression = (0, _variable.collectVariables)(this.cond);
compileTest(figure, this.loc, this._else ? "result = " : "", placeholder, templateNameForThen, childNameForThen, this.test.compile(), variablesOfExpression).declareVariable(this._else ? "result" : false);
compileCond(figure, this.loc, this.otherwise ? "result = " : "", placeholder, templateNameForThen, childNameForThen, this.cond.compile(), variablesOfExpression).declareVariable(this.otherwise ? "result" : false);
if (this._else) {
compileTest(figure, this.loc, "", placeholder, templateNameForElse, childNameForElse, "!result", variablesOfExpression);
if (this.otherwise) {
compileCond(figure, this.loc, "", placeholder, templateNameForOtherwise, childNameForOtherwise, "!result", variablesOfExpression);
}

@@ -50,4 +61,4 @@

if (this._else) {
compileBody(figure, this.loc, templateNameForElse, childNameForElse, this._else, variablesOfExpression);
if (this.otherwise) {
compileBody(figure, this.loc, templateNameForOtherwise, childNameForOtherwise, this.otherwise, variablesOfExpression);
}

@@ -67,3 +78,3 @@

function compileTest(figure, loc, prepend, placeholder, templateName, childName, result, variablesOfExpression) {
function compileCond(figure, loc, prepend, placeholder, templateName, childName, result, variablesOfExpression) {
return figure.addUpdater(loc, variablesOfExpression, function () {

@@ -70,0 +81,0 @@ return (0, _sourceNode.sourceNode)(loc, [" ", prepend, "monkberry.insert(view, ", placeholder, ", ", childName, ", ", '\'' + templateName + '\', ', "__data__, ", result, ")"]);

@@ -72,2 +72,6 @@ 'use strict';

var _block = require('./compiler/block');
var _block2 = _interopRequireDefault(_block);
var _unsafe = require('./compiler/unsafe');

@@ -79,2 +83,4 @@

var _nestedBlocks = require('./optimize/nestedBlocks');
var _entity = require('./transform/entity');

@@ -94,3 +100,3 @@

this.parsers = { 'default': _monkberryParser.parser };
this.transforms = { whitespace: _whitespace.whitespace, entity: _entity.entity };
this.transforms = { whitespace: _whitespace.whitespace, nestedBlocks: _nestedBlocks.nestedBlocks, entity: _entity.entity };
this.globals = [];

@@ -128,2 +134,3 @@ }

(0, _for2.default)(parser.ast);
(0, _block2.default)(parser.ast);
(0, _unsafe2.default)(parser.ast);

@@ -167,3 +174,8 @@ (0, _visitor.visitor)(parser.ast);

var ast = parser.parse(code, name);
try {
var ast = parser.parse(code, name);
} catch (error) {
console.error(error.toString());
throw error;
}

@@ -170,0 +182,0 @@ // Transforms

@@ -15,5 +15,7 @@ 'use strict';

trim(node, 'then');
trim(node, '_else');
trim(node, 'otherwise');
} else if (node.type == 'ForStatement') {
trim(node, 'body');
} else if (node.type == 'BlockStatement') {
trim(node, 'body');
}

@@ -20,0 +22,0 @@ });

@@ -12,2 +12,3 @@ 'use strict';

exports.lookUpOnlyOneChild = lookUpOnlyOneChild;
exports.getStringLiteralValue = getStringLiteralValue;
exports.arrayToObject = arrayToObject;

@@ -60,2 +61,6 @@ function esc(str) {

function getStringLiteralValue(literal) {
return literal.value.replace(/^["']/, '').replace(/["']$/, '');
}
function arrayToObject(array) {

@@ -62,0 +67,0 @@ var value = arguments.length <= 1 || arguments[1] === undefined ? 1 : arguments[1];

@@ -63,3 +63,3 @@ "use strict";

this.test.visit(callback);
this.cond.visit(callback);

@@ -70,5 +70,5 @@ for (var i = 0; i < this.then.length; i++) {

if (this._else) {
for (var i = 0; i < this._else.length; i++) {
this._else[i].visit(callback);
if (this.otherwise) {
for (var i = 0; i < this.otherwise.length; i++) {
this.otherwise[i].visit(callback);
}

@@ -88,2 +88,10 @@ }

ast.BlockStatementNode.prototype.visit = function (callback) {
callback(this);
for (var i = 0; i < this.body.length; i++) {
this.body[i].visit(callback);
}
};
ast.UnsafeStatementNode.prototype.visit = function (callback) {

@@ -90,0 +98,0 @@ callback(this);

@@ -42,3 +42,3 @@ (function (document) {

// Render new view.
var view = this._render(template);
var view = this._render(template, undefined, undefined, true);

@@ -56,2 +56,7 @@ // Set view hierarchy.

// Call onRender actions.
if (view.onRender) {
view.onRender();
}
// Set view data (note what it must be after adding nodes to DOM).

@@ -79,3 +84,3 @@ view.update(transform(data, array, keys, j, options));

// Render new view.
var view = this._render(template);
var view = this._render(template, undefined, undefined, true);

@@ -93,2 +98,7 @@ // Set view hierarchy.

// Call onRender actions.
if (view.onRender) {
view.onRender();
}
// Set view data (note what it must be after adding nodes to DOM).

@@ -122,4 +132,5 @@ view.update(data);

*/
Monkberry.prototype._render = function (name, values, noCache) {
Monkberry.prototype._render = function (name, values, noCache, noOnRender) {
noCache = noCache || false;
noOnRender = noOnRender || false;

@@ -142,2 +153,6 @@ if (this.templates[name]) {

if (!noOnRender && view.onRender) {
view.onRender();
}
if (values !== undefined) {

@@ -147,6 +162,2 @@ view.update(values);

if (view.onRender) {
view.onRender();
}
if (this.wrappers[name] && !view.wrapped[name]) {

@@ -153,0 +164,0 @@ view = this.wrappers[name](view);

{
"name": "monkberry",
"version": "3.6.1",
"version": "3.7.0",
"description": "JavaScript DOM Template Engine",

@@ -9,13 +9,8 @@ "bin": "bin/monkberry",

"scripts": {
"test": "node_modules/.bin/testem ci -l phantomjs",
"test": "testem ci -l phantomjs",
"toc": "doctoc --title '## Table of Contents' README.md",
"compile": "node_modules/.bin/babel -d lib/ src/",
"build": "node_modules/.bin/babel -w -d lib/ src/",
"compile": "babel -d lib/ src/",
"build": "babel -w -d lib/ src/",
"prepublish": "npm run compile"
},
"babel": {
"presets": [
"es2015"
]
},
"repository": {

@@ -39,3 +34,3 @@ "type": "git",

"commander": "^2.9.0",
"monkberry-parser": "^3.6.0",
"monkberry-parser": "^3.7.0",
"source-map": "^0.5.3",

@@ -46,2 +41,3 @@ "asciitree": "^1.0.2"

"babel-cli": "^6.4.0",
"babel-plugin-transform-flow-strip-types": "^6.4.0",
"babel-preset-es2015": "^6.3.13",

@@ -48,0 +44,0 @@ "doctoc": "^0.15.0",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc