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.7.0 to 3.7.1

66

lib/compiler/attribute.js

@@ -13,2 +13,11 @@ 'use strict';

// Transform attribute with text and expression into single expression.
//
// <div class="cat {{ dog }} {{ cow }}">
//
// Will transformed into:
//
// <div class={{ 'cat ' + dog + ' ' + cow }}>
//
var _compileToExpression = this.compileToExpression();

@@ -26,2 +35,27 @@

} else {
// When rendering attributes with more then one variable,
// Monkberry will wait for all data, before setting attribute.
//
// <div class="{{ foo }} {{ bar }}">
//
// Then you pass only one variable, no update will happen:
//
// view.update({foo});
//
// Now attribute will be set:
//
// view.update({foo, bar});
//
// On other side, if one of expression contains default value,
// Monkberry will set attribute for every variable:
//
// <div class="{{ foo }} {{ bar || 'default' }}">
//
// This will update attribute:
//
// view.update({foo});
//
// TODO: Implement other side.
figure.addUpdater(this.loc, variables, function () {

@@ -37,2 +71,10 @@ return (0, _sourceNode.sourceNode)(_this.loc, [' ', attr(_this.loc, nodeName, _this.name, expr.compile())]);

/**
* Generate code for spread operator.
*
* <div {{...attributes}}>
*
* @param {Figure} figure
* @param {string} nodeName
*/
ast.SpreadAttributeNode.prototype.compile = function (figure, nodeName) {

@@ -74,4 +116,12 @@ var _this2 = this;

// Add as default right side of "||" expression if there are no variables.
// In this example, when Monkberry will render div,
//
// <div class="{{ foo || 'default' }}">
//
// it set class attribute fo 'default'.
if ((0, _variable.collectVariables)(node.expression.right) == 0) {
defaults.push(node.expression.right.compile());
// TODO: Implement other side.
}

@@ -118,3 +168,19 @@ }

/**
* For this attributes doesn't work this:
*
* node.setAttribute('value', ...);
*
* To change them, Monkberry generate code like this:
*
* node.value = ...;
*
* @type {string[]}
*/
var plainAttributes = ['id', 'value', 'checked', 'selected'];
/**
* This attributes take boolean values, not string values.
* @type {string[]}
*/
var booleanAttributes = ['checked', 'selected'];

2

lib/compiler/block.js

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

var blockName = (0, _utils.getStringLiteralValue)(this.name);
var template = figure.name + '.' + blockName;
var template = blockName;
var child = 'child' + figure.uniqid('child_name');

@@ -15,0 +15,0 @@

@@ -47,3 +47,3 @@ 'use strict';

(function () {
// TODO: Add support for default value in attributes attr={{ value || 'default' }}.
// TODO: Add support for default value in custom tag attributes attr={{ value || 'default' }}.

@@ -50,0 +50,0 @@ var _attr$compileToExpres = attr.compileToExpression();

@@ -14,3 +14,3 @@ 'use strict';

if (this.templateNames && this.templateNames.body) {
templateName = figure.name + '.' + this.templateNames.body;
templateName = this.templateNames.body;
} else {

@@ -17,0 +17,0 @@ templateName = figure.name + '.for' + figure.uniqid('template_name');

@@ -13,3 +13,3 @@ 'use strict';

if (this.templateNames && this.templateNames.then) {
templateNameForThen = figure.name + '.' + this.templateNames.then;
templateNameForThen = this.templateNames.then;
} else {

@@ -20,3 +20,3 @@ templateNameForThen = figure.name + '.if' + figure.uniqid('template_name');

if (this.templateNames && this.templateNames.otherwise) {
templateNameForOtherwise = figure.name + '.' + this.templateNames.otherwise;
templateNameForOtherwise = this.templateNames.otherwise;
} else {

@@ -23,0 +23,0 @@ templateNameForOtherwise = templateNameForThen + '.else';

@@ -8,2 +8,4 @@ "use strict";

function visitor(ast) {
// TODO: Refactor all bunch of compilers/visitors on path way.
ast.DocumentNode.prototype.visit = function (callback) {

@@ -10,0 +12,0 @@ callback(this);

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

@@ -5,0 +5,0 @@ "bin": "bin/monkberry",

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