Skip to content

Commit

Permalink
Merge pull request #805 from slang800/remove_AST_filters
Browse files Browse the repository at this point in the history
removing ast filters closes #790
  • Loading branch information
tj committed Nov 6, 2012
2 parents 343d192 + d148caf commit 8376e06
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 122 deletions.
1 change: 0 additions & 1 deletion Readme.md
Expand Up @@ -65,7 +65,6 @@
- transparent iteration over objects, arrays, and even non-enumerables via `each`
- block comments
- no tag prefix
- AST filters
- filters
- :stylus must have [stylus](http://github.com/LearnBoost/stylus) installed
- :less must have [less.js](http://github.com/cloudhead/less.js) installed
Expand Down
8 changes: 0 additions & 8 deletions examples/nested-filters.jade

This file was deleted.

73 changes: 0 additions & 73 deletions examples/nested-filters.js

This file was deleted.

24 changes: 8 additions & 16 deletions lib/compiler.js
Expand Up @@ -409,22 +409,14 @@ Compiler.prototype = {
var fn = filters[filter.name];

// unknown filter
if (!fn) {
if (filter.isASTFilter) {
throw new Error('unknown ast filter "' + filter.name + ':"');
} else {
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)));
}
if (!fn) throw new Error('unknown filter ":' + filter.name + '"');

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)));
},

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/nodes/filter.js
Expand Up @@ -13,7 +13,7 @@ var Node = require('./node')
, Block = require('./block');

/**
* Initialize a `Filter` node with the given
* Initialize a `Filter` node with the given
* filter `name` and `block`.
*
* @param {String} name
Expand All @@ -25,7 +25,6 @@ var Filter = module.exports = function Filter(name, block, attrs) {
this.name = name;
this.block = block;
this.attrs = attrs;
this.isASTFilter = !block.nodes.every(function(node){ return node.isText });
};

/**
Expand Down
22 changes: 0 additions & 22 deletions lib/parser.js
Expand Up @@ -360,23 +360,6 @@ Parser.prototype = {
return node;
},

/**
* 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
*/
Expand Down Expand Up @@ -607,11 +590,6 @@ Parser.prototype = {
// ast-filter look-ahead
var i = 2;
if ('attrs' == this.lookahead(i).type) ++i;
if (':' == this.lookahead(i).type) {
if ('indent' == this.lookahead(++i).type) {
return this.parseASTFilter();
}
}

var tok = this.advance()
, tag = new nodes.Tag(tok.val);
Expand Down

0 comments on commit 8376e06

Please sign in to comment.