How to use the templateElement function from babel-types

Find comprehensive JavaScript babel-types.templateElement code examples handpicked from public code repositorys.

22
23
24
25
26
27
28
29
30
31

path.replaceWith(
  t.program([
    t.expressionStatement(
      t.templateLiteral([
        t.templateElement({ raw: printed }, true)
      ], [])
    )
  ])
);
fork icon6
star icon34
watch icon3

+ 11 other calls in file

214
215
216
217
218
219
220
221
    return `&${item.key.name}=`
  })
  
  expressions = expressionList.map(item => item.value)
  quasis = [ ...templateElementItemList, templateElementLastItem ].map(item => {
    return types.templateElement({ raw: item, cooked: item }, false)
  })
}
fork icon4
star icon12
watch icon2

+ 19 other calls in file

42
43
44
45
46
47
48
49
50
51
  }
},
Import(path) {
  path.parent.arguments[0] = t.templateLiteral(
    [
      t.templateElement({
        raw: prefix,
        cooked: prefix,
      }),
      t.templateElement({ raw: '&namespace', cooked: '&namespace' }, true),
fork icon1
star icon6
watch icon2

+ 39 other calls in file

37
38
39
40
41
42
43
44
45
46
if (t.isTemplateLiteral(first) && t.isStringLiteral(second)) {
  const quasi = first.quasis[first.quasis.length - 1];
  const value = typeof quasi.value === 'string' ?
    { raw: quasi.value, cooked: quasi.value } : quasi.value;
  const quasis = first.quasis.slice(0);
  quasis[quasis.length - 1] = t.templateElement({
    raw: value.raw + second.value,
    cooked: value.cooked + second.value,
  });
  return t.templateLiteral(quasis, first.expressions.slice(0));
fork icon0
star icon1
watch icon2

+ 41 other calls in file

Other functions in babel-types

Sorted by popularity

function icon

babel-types.identifier is the most popular function in babel-types (4076 examples)