Socket
Socket
Sign inDemoInstall

jade

Package Overview
Dependencies
Maintainers
2
Versions
131
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jade - npm Package Compare versions

Comparing version 0.30.0 to 0.31.0

component.json

0

index.js

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

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

35

lib/compiler.js

@@ -1,2 +0,1 @@

/*!

@@ -20,25 +19,3 @@ * Jade - Compiler

// if browser
//
// if (!Object.keys) {
// Object.keys = function(obj){
// var arr = [];
// for (var key in obj) {
// if (obj.hasOwnProperty(key)) {
// arr.push(key);
// }
// }
// return arr;
// }
// }
//
// if (!String.prototype.trimLeft) {
// String.prototype.trimLeft = function(){
// return this.replace(/^\s+/, '');
// }
// }
//
// end
/**

@@ -94,4 +71,4 @@ * Initialize `Compiler` with the given `node`.

setDoctype: function(name){
name = (name && name.toLowerCase()) || 'default';
this.doctype = doctypes[name] || '<!DOCTYPE ' + name + '>';
name = name || 'default';
this.doctype = doctypes[name.toLowerCase()] || '<!DOCTYPE ' + name + '>';
this.terse = this.doctype.toLowerCase() == '<!doctype html>';

@@ -597,3 +574,2 @@ this.xml = 0 == this.doctype.indexOf('<?xml');

+ ' $$l++;'
+ ' if ($$obj.hasOwnProperty(' + each.key + ')){'
+ ' var ' + each.val + ' = $$obj[' + each.key + '];\n');

@@ -603,4 +579,2 @@

this.buf.push(' }\n');
this.buf.push(' }\n');

@@ -660,4 +634,3 @@ if (each.alternative) {

if (classes.length) {
classes = classes.join(" + ' ' + ");
buf.push('"class": ' + classes);
buf.push('"class": [' + classes.join(',') + ']');
}

@@ -697,2 +670,2 @@

return false;
}
}

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

@@ -0,0 +0,0 @@ /*!

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

@@ -15,5 +15,4 @@ /*!

, runtime = require('./runtime')
// if node
, addWith = require('with')
, fs = require('fs');
// end

@@ -98,3 +97,3 @@ /**

// Parse
var parser = new Parser(str, options.filename, options);
var parser = new (options.parser || Parser)(str, options.filename, options);

@@ -114,3 +113,3 @@ // Compile

? 'var self = locals || {};\n' + js
: 'with (locals || {}) {\n' + js + '\n}\n')
: addWith('locals || {}', js, ['jade', 'buf'])) + ';'
+ 'return buf.join("");';

@@ -117,0 +116,0 @@ } catch (err) {

@@ -460,3 +460,3 @@ /*!

var captures;
if (captures = /^(?:- *)?(?:each|for) +(\w+)(?: *, *(\w+))? * in *([^\n]+)/.exec(this.input)) {
if (captures = /^(?:- *)?(?:each|for) +([a-zA-Z_$][\w$]*)(?: *, *([a-zA-Z_$][\w$]*))? * in *([^\n]+)/.exec(this.input)) {
this.consume(captures[0].length);

@@ -463,0 +463,0 @@ var tok = this.tok('each', captures[1]);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@@ -31,3 +31,3 @@ /*!

this.filename = filename;
this.blocks = [];
this.blocks = {};
this.mixins = {};

@@ -147,4 +147,2 @@ this.options = options;

return ast;
} else {
this.handleBlocks();
}

@@ -156,29 +154,2 @@

/**
* Handle blocks, appends and prepends. Must be called from must deep parser (which parses template that does not extends another template).
* @api private
*/
handleBlocks: function() {
this.blocks.reverse();
var blocksHash = {}; // blockName: block object
for (var i in this.blocks) {
if (!( ({}).hasOwnProperty.call(blocksHash, [this.blocks[i].name]) )) { // just safe call to blocksHash.hasOwnProperty
blocksHash[this.blocks[i].name] = this.blocks[i];
} else {
switch (this.blocks[i].mode) {
case 'append':
blocksHash[this.blocks[i].name].nodes = blocksHash[this.blocks[i].name].nodes.concat(this.blocks[i].nodes);
break;
case 'prepend':
blocksHash[this.blocks[i].name].nodes = this.blocks[i].nodes.concat(blocksHash[this.blocks[i].name].nodes);
break;
default:
blocksHash[this.blocks[i].name].nodes = this.blocks[i].nodes;
}
this.blocks[i] = blocksHash[this.blocks[i].name];
}
}
},
/**
* Expect the given type, or throw an exception.

@@ -456,3 +427,3 @@ *

parser.blocks = this.blocks.reverse();
parser.blocks = this.blocks;
parser.contexts = this.contexts;

@@ -478,6 +449,26 @@ this.extending = parser;

var prev = this.blocks[name] || {prepended: [], appended: []}
if (prev.mode === 'replace') return this.blocks[name] = prev;
var allNodes = prev.prepended.concat(block.nodes).concat(prev.appended);
switch (mode) {
case 'append':
prev.appended = prev.parser === this ?
prev.appended.concat(block.nodes) :
block.nodes.concat(prev.appended);
break;
case 'prepend':
prev.prepended = prev.parser === this ?
block.nodes.concat(prev.prepended) :
prev.prepended.concat(block.nodes);
break;
}
block.nodes = allNodes;
block.appended = prev.appended;
block.prepended = prev.prepended;
block.mode = mode;
block.name = name;
this.blocks.push(block);
return block;
block.parser = this;
return this.blocks[name] = block;
},

@@ -504,3 +495,3 @@

var parser = new Parser(str, path, this.options);
parser.blocks = utils.merge([], this.blocks);
parser.blocks = utils.merge({}, this.blocks);

@@ -532,2 +523,6 @@ parser.mixins = this.mixins;

this.tag(mixin);
if (mixin.code) {
mixin.block.push(mixin.code);
mixin.code = null;
}
if (mixin.block.isEmpty()) mixin.block = null;

@@ -708,2 +703,6 @@ return mixin;

if (tag.textOnly && !dot && !(tag.name == 'script' && tag.getAttribute('src'))) {
console.warn('Implicit textOnly for `script` and `style` is deprecated. Use `script.` or `style.` instead.');
}
// block?

@@ -710,0 +709,0 @@ if ('indent' == this.peek().type) {

@@ -55,5 +55,3 @@

if (!Array.isArray(bc)) bc = [bc];
ac = ac.filter(nulls);
bc = bc.filter(nulls);
a['class'] = ac.concat(bc).join(' ');
a['class'] = ac.concat(bc).filter(nulls);
}

@@ -73,4 +71,4 @@

*
* @param {Mixed} val
* @return {Mixed}
* @param {*} val
* @return {Boolean}
* @api private

@@ -80,6 +78,18 @@ */

function nulls(val) {
return val != null;
return val != null && val !== '';
}
/**
* join array as classes.
*
* @param {*} val
* @return {String}
* @api private
*/
function joinClasses(val) {
return Array.isArray(val) ? val.map(joinClasses).filter(nulls).join(' ') : val;
}
/**
* Render the given attributes object.

@@ -115,4 +125,6 @@ *

buf.push(key + "='" + JSON.stringify(val) + "'");
} else if ('class' == key && Array.isArray(val)) {
buf.push(key + '="' + exports.escape(val.join(' ')) + '"');
} else if ('class' == key) {
if (val = exports.escape(joinClasses(val))) {
buf.push(key + '="' + val + '"');
}
} else if (escaped && escaped[key]) {

@@ -119,0 +131,0 @@ buf.push(key + '="' + exports.escape(val) + '"');

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

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

{
"name": "jade",
"description": "Jade template engine",
"version": "0.30.0",
"version": "0.31.0",
"author": "TJ Holowaychuk <tj@vision-media.ca>",

@@ -13,7 +13,8 @@ "repository": "git://github.com/visionmedia/jade",

"dependencies": {
"commander": "~1.1.1",
"commander": "1.1.1",
"mkdirp": "0.3.x",
"transformers": "~2.0.1",
"character-parser": "~1.0.0",
"monocle": "~0.1.46"
"transformers": "2.0.1",
"character-parser": "1.0.2",
"monocle": "0.1.46",
"with": "1.0.3"
},

@@ -28,3 +29,4 @@ "devDependencies": {

"less": "*",
"uglify-js": "*"
"uglify-js": "*",
"browserify": "*"
},

@@ -38,4 +40,11 @@ "component": {

"test": "mocha -R spec",
"prepublish": "npm prune"
"prepublish": "npm prune",
"build": "npm run compile",
"compile": "npm run compile-full && npm run compile-runtime",
"compile-full": "browserify ./lib/jade.js --standalone jade -x ./node_modules/transformers > jade.js",
"compile-runtime": "browserify ./lib/runtime.js --standalone jade > runtime.js"
},
"browser": {
"./lib/filters.js": "./lib/filters-client.js"
}
}

@@ -447,7 +447,7 @@ # Jade - 模板引擎

doctype html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN
doctype html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN"
渲染后:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN">

@@ -454,0 +454,0 @@ 会输出 _html 5_ 文档类型. 下面的默认的文档类型,可以很简单的扩展:

@@ -8,2 +8,10 @@ # Jade - template engine

## Anouncment
Jade version 0.31.0 deprecated implicit text only support for scripts and styles. To fix this all you need to do is add a `.` character after the script or style tag.
It is hoped that this change will make jade easier for newcommers to learn without affecting the power of the language or leading to excessive verboseness.
If you have a lot of jade files that need fixing you can use [fix-jade](https://github.com/ForbesLindesay/fix-jade) to attempt to automate the process.
## Test drive

@@ -289,20 +297,5 @@

Tags that accept _only_ text such as `script` and `style` do not
need the leading `|` character, for example:
As an alternative, we may use a trailing `.` to indicate a text block, for example:
```jade
html
head
title Example
script
if (foo) {
bar();
} else {
baz();
}
```
Once again as an alternative, we may use a trailing `.` to indicate a text block, for example:
```jade
p.

@@ -642,3 +635,3 @@ foo asdf

```jade
doctype html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN
doctype html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN"
```

@@ -649,3 +642,3 @@

```html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN">
```

@@ -652,0 +645,0 @@

@@ -0,3 +1,4 @@

(function(e){if("function"==typeof bootstrap)bootstrap("jade",e);else if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeJade=e}else"undefined"!=typeof window?window.jade=e():global.jade=e()})(function(){var define,ses,bootstrap,module,exports;
return (function(e,t,n){function i(n,s){if(!t[n]){if(!e[n]){var o=typeof require=="function"&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);throw new Error("Cannot find module '"+n+"'")}var u=t[n]={exports:{}};e[n][0].call(u.exports,function(t){var r=e[n][1][t];return i(r?r:t)},u,u.exports)}return t[n].exports}var r=typeof require=="function"&&require;for(var s=0;s<n.length;s++)i(n[s]);return i})({1:[function(require,module,exports){
jade = (function(exports){
/*!

@@ -56,5 +57,3 @@ * Jade - runtime

if (!Array.isArray(bc)) bc = [bc];
ac = ac.filter(nulls);
bc = bc.filter(nulls);
a['class'] = ac.concat(bc).join(' ');
a['class'] = ac.concat(bc).filter(nulls);
}

@@ -74,4 +73,4 @@

*
* @param {Mixed} val
* @return {Mixed}
* @param {*} val
* @return {Boolean}
* @api private

@@ -81,6 +80,18 @@ */

function nulls(val) {
return val != null;
return val != null && val !== '';
}
/**
* join array as classes.
*
* @param {*} val
* @return {String}
* @api private
*/
function joinClasses(val) {
return Array.isArray(val) ? val.map(joinClasses).filter(nulls).join(' ') : val;
}
/**
* Render the given attributes object.

@@ -116,4 +127,6 @@ *

buf.push(key + "='" + JSON.stringify(val) + "'");
} else if ('class' == key && Array.isArray(val)) {
buf.push(key + '="' + exports.escape(val.join(' ')) + '"');
} else if ('class' == key) {
if (val = exports.escape(joinClasses(val))) {
buf.push(key + '="' + val + '"');
}
} else if (escaped && escaped[key]) {

@@ -140,3 +153,3 @@ buf.push(key + '="' + exports.escape(val) + '"');

return String(html)
.replace(/&(?!(\w+|\#\d+);)/g, '&amp;')
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')

@@ -159,2 +172,3 @@ .replace(/>/g, '&gt;')

if (!filename) throw err;
if (typeof window != 'undefined') throw err;

@@ -183,4 +197,7 @@ var context = 3

return exports;
},{"fs":2}],2:[function(require,module,exports){
// nothing to see here... no file methods for the browser
})({});
},{}]},{},[1])(1)
});
;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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