root 3bf41bf355 update | 1 سال پیش | |
---|---|---|
.. | ||
CHANGELOG.md | 1 سال پیش | |
LICENSE.md | 1 سال پیش | |
README.md | 1 سال پیش | |
index.js | 1 سال پیش | |
package.json | 1 سال پیش |
Strips comments from Pug token stream
npm install pug-strip-comments
var lex = require('pug-lexer');
var stripComments = require('pug-strip-comments');
var tokens = lex('//- unbuffered\n// buffered');
// [ { type: 'comment', line: 1, val: ' unbuffered', buffer: false },
// { type: 'newline', line: 2 },
// { type: 'comment', line: 2, val: ' buffered', buffer: true },
// { type: 'eos', line: 2 } ]
// Only strip unbuffered comments (default)
stripComments(tokens, { filename: 'pug' });
// [ { type: 'newline', line: 2 },
// { type: 'comment', line: 2, val: ' buffered', buffer: true },
// { type: 'eos', line: 2 } ]
// Only strip buffered comments (when you want to play a joke on your coworkers)
stripComments(tokens, { filename: 'pug', stripUnbuffered: false, stripBuffered: true });
// [ { type: 'comment', line: 1, val: ' unbuffered', buffer: false },
// { type: 'newline', line: 2 },
// { type: 'eos', line: 2 } ]
// Strip both (if you want Pug VERY clean)
stripComments(tokens, { filename: 'pug', stripBuffered: true });
// [ { type: 'newline', line: 2 },
// { type: 'eos', line: 2 } ]
MIT