Socket
Socket
Sign inDemoInstall

jade

Package Overview
Dependencies
Maintainers
1
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.27.7 to 0.28.0

Readme_zh-cn.md

26

lib/compiler.js

@@ -412,18 +412,10 @@

// unknown filter
if (!fn) {
if (filter.isASTFilter) {
throw new Error('unknown ast filter "' + filter.name + ':"');
} else {
throw new Error('unknown filter ":' + filter.name + '"');
}
}
if (!fn) throw new Error('unknown filter ":' + filter.name + '"');
if (filter.isASTFilter) {
this.buf.push(fn(filter.block, this, filter.attrs));
} else {
var text = filter.block.nodes.map(function(node){ return node.val }).join('\n');
filter.attrs = filter.attrs || {};
filter.attrs.filename = this.options.filename;
this.buffer(utils.text(fn(text, filter.attrs)));
}
var text = filter.block.nodes.map(
function(node){ return node.val; }
).join('\n');
filter.attrs = filter.attrs || {};
filter.attrs.filename = this.options.filename;
this.buffer(utils.text(fn(text, filter.attrs)));
},

@@ -613,7 +605,7 @@

classes = classes.join(" + ' ' + ");
buf.push("class: " + classes);
buf.push('"class": ' + classes);
}
return {
buf: buf.join(', ').replace('class:', '"class":'),
buf: buf.join(', '),
escaped: JSON.stringify(escaped),

@@ -620,0 +612,0 @@ inherits: inherits,

@@ -8,90 +8,99 @@

module.exports = {
/**
* Wrap text with CDATA block.
*/
cdata: function(str){
return '<![CDATA[\\n' + str + '\\n]]>';
},
/**
* Transform sass to css, wrapped in style tags.
*/
sass: function(str){
str = str.replace(/\\n/g, '\n');
var sass = require('sass').render(str).replace(/\n/g, '\\n');
return '<style type="text/css">' + sass + '</style>';
},
/**
* Transform stylus to css, wrapped in style tags.
*/
stylus: function(str, options){
var ret;
str = str.replace(/\\n/g, '\n');
var stylus = require('stylus');
stylus(str, options).render(function(err, css){
if (err) throw err;
ret = css.replace(/\n/g, '\\n');
});
return '<style type="text/css">' + ret + '</style>';
},
/**
* Transform less to css, wrapped in style tags.
*/
less: function(str){
var ret;
str = str.replace(/\\n/g, '\n');
require('less').render(str, function(err, css){
if (err) throw err;
ret = '<style type="text/css">' + css.replace(/\n/g, '\\n') + '</style>';
});
return ret;
},
/**
* Transform markdown to html.
*/
markdown: function(str){
var md;
/**
* Wrap text with CDATA block.
*/
// support markdown / discount
exports.cdata = function(str){
return '<![CDATA[\\n' + str + '\\n]]>';
};
/**
* Wrap text in script tags.
*/
exports.js = function(str){
return '<script>' + str + '</script>';
};
/**
* Wrap text in style tags.
*/
exports.css = function(str){
return '<style>' + str + '</style>';
};
/**
* Transform stylus to css, wrapped in style tags.
*/
exports.stylus = function(str, options){
var ret;
str = str.replace(/\\n/g, '\n');
var stylus = require('stylus');
stylus(str, options).render(function(err, css){
if (err) throw err;
ret = css.replace(/\n/g, '\\n');
});
return '<style type="text/css">' + ret + '</style>';
};
/**
* Transform less to css, wrapped in style tags.
*/
exports.less = function(str){
var ret;
str = str.replace(/\\n/g, '\n');
require('less').render(str, function(err, css){
if (err) throw err;
ret = '<style type="text/css">' + css.replace(/\n/g, '\\n') + '</style>';
});
return ret;
};
/**
* Transform markdown to html.
*/
exports.markdown = function(str){
var md;
// support markdown / discount
try {
md = require('markdown');
} catch (err){
try {
md = require('markdown');
} catch (err){
md = require('discount');
} catch (err) {
try {
md = require('discount');
md = require('markdown-js');
} catch (err) {
try {
md = require('markdown-js');
md = require('marked');
} catch (err) {
try {
md = require('marked');
} catch (err) {
throw new
Error('Cannot find markdown library, install markdown, discount, or marked.');
}
throw new
Error('Cannot find markdown library, install markdown, discount, or marked.');
}
}
}
}
str = str.replace(/\\n/g, '\n');
return md.parse(str).replace(/\n/g, '\\n').replace(/'/g,'&#39;');
},
/**
* Transform coffeescript to javascript.
*/
str = str.replace(/\\n/g, '\n');
return md.parse(str).replace(/\n/g, '\\n').replace(/'/g,'&#39;');
};
coffeescript: function(str){
var js = require('coffee-script').compile(str).replace(/\\/g, '\\\\').replace(/\n/g, '\\n');
return '<script type="text/javascript">\\n' + js + '</script>';
}
/**
* Transform coffeescript to javascript.
*/
exports.coffeescript = function(str){
var js = require('coffee-script').compile(str).replace(/\\/g, '\\\\').replace(/\n/g, '\\n');
return '<script type="text/javascript">\\n' + js + '</script>';
};
// aliases
exports.md = exports.markdown;
exports.styl = exports.stylus;
exports.coffee = exports.coffeescript;

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

exports.version = '0.27.7';
exports.version = '0.28.0';

@@ -26,0 +26,0 @@ /**

@@ -16,3 +16,3 @@

/**
* Initialize a `Filter` node with the given
* Initialize a `Filter` node with the given
* filter `name` and `block`.

@@ -29,3 +29,2 @@ *

this.attrs = attrs;
this.isASTFilter = !block.nodes.every(function(node){ return node.isText });
};

@@ -32,0 +31,0 @@

@@ -14,3 +14,6 @@

, nodes = require('./nodes')
, utils = require('./utils');
, utils = require('./utils')
, filters = require('./filters')
, path = require('path')
, extname = path.extname;

@@ -82,3 +85,3 @@ /**

},
/**

@@ -90,7 +93,7 @@ * Single token lookahead.

*/
peek: function() {
return this.lookahead(1);
},
/**

@@ -102,7 +105,7 @@ * Return lexer lineno.

*/
line: function() {
return this.lexer.lineno;
},
/**

@@ -115,7 +118,7 @@ * `n` token lookahead.

*/
lookahead: function(n){
return this.lexer.lookahead(n);
},
/**

@@ -127,3 +130,3 @@ * Parse input returning a string of js for evaluation.

*/
parse: function(){

@@ -153,3 +156,3 @@ var block = new nodes.Block, parser;

},
/**

@@ -161,3 +164,3 @@ * Expect the given type, or throw an exception.

*/
expect: function(type){

@@ -170,3 +173,3 @@ if (this.peek().type === type) {

},
/**

@@ -178,3 +181,3 @@ * Accept the given `type`.

*/
accept: function(type){

@@ -185,3 +188,3 @@ if (this.peek().type === type) {

},
/**

@@ -202,3 +205,3 @@ * tag

*/
parseExpr: function(){

@@ -253,7 +256,7 @@ switch (this.peek().type) {

},
/**
* Text
*/
parseText: function(){

@@ -300,3 +303,3 @@ var tok = this.expect('text')

},
/**

@@ -314,3 +317,3 @@ * default

*/
parseCode: function(){

@@ -330,7 +333,7 @@ var tok = this.expect('code')

},
/**
* comment
*/
parseComment: function(){

@@ -349,7 +352,7 @@ var tok = this.expect('comment')

},
/**
* doctype
*/
parseDoctype: function(){

@@ -361,7 +364,7 @@ var tok = this.expect('doctype')

},
/**
* filter attrs? text-block
*/
parseFilter: function(){

@@ -380,24 +383,7 @@ var block

},
/**
* tag ':' attrs? block
*/
parseASTFilter: function(){
var block
, tok = this.expect('tag')
, attrs = this.accept('attrs');
this.expect(':');
block = this.block();
var node = new nodes.Filter(tok.val, block, attrs && attrs.attrs);
node.line = this.line();
return node;
},
/**
* each block
*/
parseEach: function(){

@@ -500,10 +486,13 @@ var tok = this.expect('each')

if ('.jade' != path.substr(-5)) {
var path = join(dir, path)
, str = fs.readFileSync(path, 'utf8');
var path = join(dir, path);
var str = fs.readFileSync(path, 'utf8');
var ext = extname(path).slice(1);
var filter = filters[ext];
if (filter) str = filter(str);
return new nodes.Literal(str);
}
var path = join(dir, path)
, str = fs.readFileSync(path, 'utf8')
, parser = new Parser(str, path, this.options);
var path = join(dir, path);
var str = fs.readFileSync(path, 'utf8');
var parser = new Parser(str, path, this.options);
parser.blocks = utils.merge({}, this.blocks);

@@ -595,3 +584,3 @@ parser.mixins = this.mixins;

*/
block: function(){

@@ -615,3 +604,3 @@ var block = new nodes.Block;

*/
parseInterpolation: function(){

@@ -627,3 +616,3 @@ var tok = this.advance();

*/
parseTag: function(){

@@ -633,7 +622,2 @@ // ast-filter look-ahead

if ('attrs' == this.lookahead(i).type) ++i;
if (':' == this.lookahead(i).type) {
if ('indent' == this.lookahead(++i).type) {
return this.parseASTFilter();
}
}

@@ -736,5 +720,5 @@ var tok = this.advance()

}
return tag;
}
};
{
"name": "jade",
"description": "Jade template engine",
"version": "0.27.7",
"version": "0.28.0",
"author": "TJ Holowaychuk <tj@vision-media.ca>",

@@ -6,0 +6,0 @@ "repository": "git://github.com/visionmedia/jade",

@@ -68,3 +68,2 @@ [![Build Status](https://secure.travis-ci.org/visionmedia/jade.png)](http://travis-ci.org/visionmedia/jade)

- no tag prefix
- AST filters
- filters

@@ -71,0 +70,0 @@ - :stylus must have [stylus](http://github.com/LearnBoost/stylus) installed

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