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

Function parseTemplate

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

Source from the content-addressed store, hash-verified

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