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

pug-attrs

Package Overview
Dependencies
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pug-attrs - npm Package Compare versions

Comparing version 2.0.4 to 3.0.0-canary-1

60

index.js

@@ -9,6 +9,6 @@ 'use strict';

function isConstant(src) {
return constantinople(src, {pug: runtime, 'pug_interp': undefined});
return constantinople(src, {pug: runtime, pug_interp: undefined});
}
function toConstant(src) {
return constantinople.toConstant(src, {pug: runtime, 'pug_interp': undefined});
return constantinople.toConstant(src, {pug: runtime, pug_interp: undefined});
}

@@ -25,12 +25,20 @@

assert(Array.isArray(attrs), 'Attrs should be an array');
assert(attrs.every(function (attr) {
return attr &&
typeof attr === 'object' &&
typeof attr.name === 'string' &&
(typeof attr.val === 'string' || typeof attr.val === 'boolean') &&
typeof attr.mustEscape === 'boolean';
}), 'All attributes should be supplied as an object of the form {name, val, mustEscape}');
assert(
attrs.every(function(attr) {
return (
attr &&
typeof attr === 'object' &&
typeof attr.name === 'string' &&
(typeof attr.val === 'string' || typeof attr.val === 'boolean') &&
typeof attr.mustEscape === 'boolean'
);
}),
'All attributes should be supplied as an object of the form {name, val, mustEscape}'
);
assert(options && typeof options === 'object', 'Options should be an object');
assert(typeof options.terse === 'boolean', 'Options.terse should be a boolean');
assert(
typeof options.terse === 'boolean',
'Options.terse should be a boolean'
);
assert(
typeof options.runtime === 'function',

@@ -51,3 +59,5 @@ 'Options.runtime should be a function that takes a runtime function name and returns the source code that will evaluate to that function at runtime'

if (options.format === 'html') {
var str = stringify(runtime.attr(key, toConstant(val), mustEscape, options.terse));
var str = stringify(
runtime.attr(key, toConstant(val), mustEscape, options.terse)
);
var last = buf[buf.length - 1];

@@ -68,3 +78,14 @@ if (last && last[last.length - 1] === str[0]) {

if (options.format === 'html') {
buf.push(options.runtime('attr') + '("' + key + '", ' + val + ', ' + stringify(mustEscape) + ', ' + stringify(options.terse) + ')');
buf.push(
options.runtime('attr') +
'("' +
key +
'", ' +
val +
', ' +
stringify(mustEscape) +
', ' +
stringify(options.terse) +
')'
);
} else {

@@ -79,3 +100,3 @@ if (mustEscape) {

attrs.forEach(function(attr){
attrs.forEach(function(attr) {
var key = attr.name;

@@ -109,5 +130,7 @@ var val = attr.val;

} else {
classes = classes.map(function (cls, i) {
classes = classes.map(function(cls, i) {
if (isConstant(cls)) {
cls = stringify(classEscaping[i] ? runtime.escape(toConstant(cls)) : toConstant(cls));
cls = stringify(
classEscaping[i] ? runtime.escape(toConstant(cls)) : toConstant(cls)
);
classEscaping[i] = false;

@@ -119,3 +142,8 @@ }

'class',
options.runtime('classes') + '([' + classes.join(',') + '], ' + stringify(classEscaping) + ')',
options.runtime('classes') +
'([' +
classes.join(',') +
'], ' +
stringify(classEscaping) +
')',
false,

@@ -122,0 +150,0 @@ classesBuf

{
"name": "pug-attrs",
"version": "2.0.4",
"version": "3.0.0-canary-1",
"description": "Generate code for Pug attributes",

@@ -9,5 +9,5 @@ "keywords": [

"dependencies": {
"constantinople": "^3.0.1",
"js-stringify": "^1.0.1",
"pug-runtime": "^2.0.5"
"constantinople": "^4.0.1",
"js-stringify": "^1.0.2",
"pug-runtime": "3.0.0-canary-1"
},

@@ -22,4 +22,3 @@ "files": [

"author": "Forbes Lindesay",
"license": "MIT",
"gitHead": "1bdf628a70fda7a0d840c52f3abce54b1c6b0130"
"license": "MIT"
}
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