MCPcopy Create free account
hub / github.com/babel/babel / parseTemplate

Function parseTemplate

packages/babel-parser/src/parser/expression.ts:2054–2069  ·  view source on GitHub ↗
(this: Parser, isTagged: boolean)

Source from the content-addressed store, hash-verified

2052
2053 // https://tc39.es/ecma262/#prod-TemplateLiteral
2054 parseTemplate(this: Parser, isTagged: boolean): N.TemplateLiteral {
2055 const node = this.startNode<N.TemplateLiteral>();
2056 let curElt = this.parseTemplateElement(isTagged);
2057 const quasis = [curElt];
2058 const substitutions = [];
2059 while (!curElt.tail) {
2060 substitutions.push(this.parseTemplateSubstitution());
2061 this.readTemplateContinuation();
2062 quasis.push((curElt = this.parseTemplateElement(isTagged)));
2063 }
2064 // Type cast from (N.Expression[] | N.TSType[]). parseTemplateSubstitution
2065 // returns consistent results.
2066 node.expressions = substitutions;
2067 node.quasis = quasis;
2068 return this.finishNode(node, "TemplateLiteral");
2069 }
2070
2071 // This is overwritten by the TypeScript plugin to parse template types
2072 parseTemplateSubstitution(this: Parser): N.Expression | N.TSType {

Callers

nothing calls this directly

Calls 3

finishNodeMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected