MCPcopy
hub / github.com/vuejs/core / genTemplateLiteral

Function genTemplateLiteral

packages/compiler-core/src/codegen.ts:1046–1064  ·  view source on GitHub ↗
(node: TemplateLiteral, context: CodegenContext)

Source from the content-addressed store, hash-verified

1044}
1045
1046function genTemplateLiteral(node: TemplateLiteral, context: CodegenContext) {
1047 const { push, indent, deindent } = context
1048 push('`')
1049 const l = node.elements.length
1050 const multilines = l > 3
1051 for (let i = 0; i < l; i++) {
1052 const e = node.elements[i]
1053 if (isString(e)) {
1054 push(e.replace(/(`|\$|\\)/g, '\\$1'), NewlineType.Unknown)
1055 } else {
1056 push('${')
1057 if (multilines) indent()
1058 genNode(e, context)
1059 if (multilines) deindent()
1060 push('}')
1061 }
1062 }
1063 push('`')
1064}
1065
1066function genIfStatement(node: IfStatement, context: CodegenContext) {
1067 const { push, indent, deindent } = context

Callers 1

genNodeFunction · 0.85

Calls 5

isStringFunction · 0.90
indentFunction · 0.85
genNodeFunction · 0.85
deindentFunction · 0.85
pushFunction · 0.70

Tested by

no test coverage detected