root 3bf41bf355 update | 1 år sedan | |
---|---|---|
.. | ||
CHANGELOG.md | 1 år sedan | |
LICENSE.md | 1 år sedan | |
README.md | 1 år sedan | |
index.js | 1 år sedan | |
package.json | 1 år sedan |
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