Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: keep lexer plugins inside tag interpolation #3296

Merged
merged 1 commit into from Feb 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/pug-lexer/index.js
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
@@ -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);
});