You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
864 B

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