Skip to content

Commit

Permalink
fix: keep lexer plugins inside tag interpolation (#3296)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhendric authored Feb 28, 2021
1 parent 29a53c5 commit 73ea7cf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/pug-lexer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ Lexer.prototype = {
interpolated: true,
startingLine: this.lineno,
startingColumn: this.colno,
plugins: this.plugins,
});
var interpolated;
try {
Expand Down
18 changes: 18 additions & 0 deletions packages/pug/test/plugins.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const pug = require('../');

test('#3295 - lexer plugins should be used in tag interpolation', () => {
const lex = {
advance(lexer) {
if ('~' === lexer.input.charAt(0)) {
lexer.tokens.push(lexer.tok('text', 'twiddle-dee-dee'));
lexer.consume(1);
lexer.incrementColumn(1);
return true;
}
},
};
const input = 'p Look at #[~]';
const expected = '<p>Look at twiddle-dee-dee</p>';
const output = pug.render(input, {plugins: [{lex}]});
expect(output).toEqual(expected);
});

0 comments on commit 73ea7cf

Please sign in to comment.