template-literals.js 778 B

12345678910111213141516171819202122232425262728293031
  1. "use strict";
  2. exports.__esModule = true;
  3. exports.TaggedTemplateExpression = TaggedTemplateExpression;
  4. exports.TemplateElement = TemplateElement;
  5. exports.TemplateLiteral = TemplateLiteral;
  6. function TaggedTemplateExpression(node) {
  7. this.print(node.tag, node);
  8. this.print(node.quasi, node);
  9. }
  10. function TemplateElement(node, parent) {
  11. var isFirst = parent.quasis[0] === node;
  12. var isLast = parent.quasis[parent.quasis.length - 1] === node;
  13. var value = (isFirst ? "`" : "}") + node.value.raw + (isLast ? "`" : "${");
  14. this.token(value);
  15. }
  16. function TemplateLiteral(node) {
  17. var quasis = node.quasis;
  18. for (var i = 0; i < quasis.length; i++) {
  19. this.print(quasis[i], node);
  20. if (i + 1 < quasis.length) {
  21. this.print(node.expressions[i], node);
  22. }
  23. }
  24. }