How to use the templateLiteral function from babel-types
Find comprehensive JavaScript babel-types.templateLiteral code examples handpicked from public code repositorys.
13 14 15 16 17 18 19 20 21 22
}) references.styled.forEach(styledRef => { if (styledRef.parentPath.parentPath.type === 'TaggedTemplateExpression') { const quasi = styledRef.parentPath.parentPath.get('quasi') const val = quasi.evaluate().value.trim() const replacement = t.templateLiteral([t.templateElement(val)], []) quasi.replaceWith(replacement) } }) }
157
0
2
+ 11 other calls in file
21 22 23 24 25 26 27 28 29 30
let printed = printAST(exploded) + '\n'; path.replaceWith( t.program([ t.expressionStatement( t.templateLiteral([ t.templateElement({ raw: printed }, true) ], []) ) ])
6
34
3
+ 11 other calls in file
40 41 42 43 44 45 46 47 48 49
) ) } }, Import(path) { path.parent.arguments[0] = t.templateLiteral( [ t.templateElement({ raw: prefix, cooked: prefix,
1
6
2
+ 19 other calls in file
30 31 32 33 34 35 36 37 38 39
const quasis = second.quasis.slice(0); quasis[0] = t.templateElement({ raw: first.value + value.raw, cooked: first.value + value.cooked, }); return t.templateLiteral(quasis, second.expressions.slice(0)); } if (t.isTemplateLiteral(first) && t.isStringLiteral(second)) { const quasi = first.quasis[first.quasis.length - 1]; const value = typeof quasi.value === 'string' ?
0
1
0
+ 41 other calls in file
217 218 219 220 221 222 223 224 225 226
expressions = expressionList.map(item => item.value) quasis = [ ...templateElementItemList, templateElementLastItem ].map(item => { return types.templateElement({ raw: item, cooked: item }, false) }) } const newTemplateLiteral = types.templateLiteral(quasis, expressions) const objectProperty = types.objectProperty(url, newTemplateLiteral, false, false, null) // 构造一个CallExpression let newPoperty
3
12
0
GitHub: chenpeng-98/vue2wx
308 309 310 311 312 313 314 315 316 317
expressions = expressionList.map(item => item.value) quasis = [...templateElementItemList, templateElementLastItem].map(item => { return types.templateElement({ raw: item, cooked: item }, false) }) } const newTemplateLiteral = types.templateLiteral(quasis, expressions) //创建一个 templateLiteral const objectProperty = types.objectProperty(url, newTemplateLiteral, false, false, null) // 构造一个CallExpression let newPoperty if (property.name === 'replace') {
0
0
0
babel-types.identifier is the most popular function in babel-types (4076 examples)