Skip to content

Instantly share code, notes, and snippets.

@ericmorand
Created February 24, 2020 18:09
Show Gist options
  • Save ericmorand/073d2aba55c50da5f686641a2644ccbe to your computer and use it in GitHub Desktop.
Save ericmorand/073d2aba55c50da5f686641a2644ccbe to your computer and use it in GitHub Desktop.
no-op trans tag support for Twing
import {TwingTokenParser} from "../token-parser";
import {Token, TokenType} from "twig-lexer";
export class TwingTokenParserTrans extends TwingTokenParser {
parse(token: Token) {
let stream = this.parser.getStream();
stream.expect(TokenType.TAG_END);
let body = this.parser.subparse([this, this.decideBlockEnd], true);
stream.expect(TokenType.TAG_END);
return body;
}
decideBlockEnd(token: Token) {
return token.test(TokenType.NAME, 'endtrans');
}
getTag() {
return 'trans';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment