Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added block comment support

  • Loading branch information...
commit a524ef130d522be6d845c1a0fd0c6da3a8f16da7 1 parent 916724a
@tj tj authored
View
20 Readme.md
@@ -17,6 +17,7 @@
- parse tree manipulation via _filters_
- supports [Express JS](http://expressjs.com) out of the box
- transparent iteration over objects, arrays, and even non-enumerables via `- each`
+ - block comments
- no tag prefix
- filters
- :sass must have [sass.js](http://github.com/visionmedia/sass.js) installed
@@ -184,6 +185,25 @@ outputting
<p>foo</p>
<p>bar</p>
+### Block Comments
+
+ A block comment is the `/` character followed by a block.
+
+ body
+ /
+ #content
+ h1 Example
+
+outputting
+
+ <body>
+ <!--
+ <div id="content">
+ <h1>Example</h1>
+ </div>
+ -->
+ </body>
+
### Nesting
ul
View
13 lib/compiler.js
@@ -199,6 +199,19 @@ Compiler.prototype = {
},
/**
+ * Visit a `BlockComment`.
+ *
+ * @param {Comment} comment
+ * @api public
+ */
+
+ visitBlockComment: function(comment){
+ this.buffer('<!--');
+ this.visit(comment.block);
+ this.buffer('-->');
+ },
+
+ /**
* Visit `code`, respecting buffer / escape flags.
* If the code is followed by a block, wrap it in
* a self-calling function.
View
29 lib/nodes/block-comment.js
@@ -0,0 +1,29 @@
+
+/*!
+ * Jade - nodes - BlockComment
+ * Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>
+ * MIT Licensed
+ */
+
+/**
+ * Module dependencies.
+ */
+
+var Node = require('./node');
+
+/**
+ * Initialize a `BlockComment` with the given `block`.
+ *
+ * @param {Block} block
+ * @api public
+ */
+
+var BlockComment = module.exports = function BlockComment(block) {
+ this.block = block;
+};
+
+/**
+ * Inherit from `Node`.
+ */
+
+BlockComment.prototype.__proto__ = Node.prototype;
View
1  lib/nodes/index.js
@@ -13,4 +13,5 @@ exports.Text = require('./text');
exports.Block = require('./block');
exports.Filter = require('./filter');
exports.Comment = require('./comment');
+exports.BlockComment = require('./block-comment');
exports.Doctype = require('./doctype');
View
14 lib/parser.js
@@ -161,6 +161,8 @@ Parser.prototype = {
return this.parseFilter();
case 'comment':
return this.parseComment();
+ case 'block-comment':
+ return this.parseBlockComment();
case 'text':
return this.parseText();
case 'each':
@@ -202,6 +204,18 @@ Parser.prototype = {
}
return node;
},
+
+ /**
+ * block comment
+ */
+
+ parseBlockComment: function(){
+ var tok = this.expect('block-comment')
+ , node = new nodes.BlockComment(this.parseBlock());
+ node.line = this.line;
+ return node;
+ },
+
/**
* comment
Please sign in to comment.
Something went wrong with that request. Please try again.