-
Notifications
You must be signed in to change notification settings - Fork 439
Expand file tree
/
Copy pathtext.ts
More file actions
26 lines (22 loc) · 875 Bytes
/
text.ts
File metadata and controls
26 lines (22 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
* Copyright (c) 2024, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import {
generateConcatenatedTextNodesExpressions,
generateExpressionFromTextNode,
isLastConcatenatedNode,
} from '../adjacent-text-nodes';
import type { Statement as EsStatement } from 'estree';
import type { Text as IrText } from '@lwc/template-compiler';
import type { Transformer } from '../types';
export const Text: Transformer<IrText> = function Text(node, cxt): EsStatement[] {
const valueToYield = generateExpressionFromTextNode(node, cxt);
if (!isLastConcatenatedNode(cxt)) {
cxt.bufferedTextNodeValues.push(valueToYield);
return [];
}
return generateConcatenatedTextNodesExpressions(cxt, valueToYield);
};