@marko/translator-default 6.0.10 → 6.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,7 +19,7 @@ var _withPreviousLocation = _interopRequireDefault(require("../../../util/with-p
19
19
  } else {
20
20
  value.parentPath.remove();
21
21
  }
22
- } else {
22
+ } else if (!value.isTemplateLiteral()) {
23
23
  value.replaceWith(
24
24
  (0, _withPreviousLocation.default)(
25
25
  _compiler.types.callExpression(
@@ -19,7 +19,7 @@ var _withPreviousLocation = _interopRequireDefault(require("../../../util/with-p
19
19
  } else {
20
20
  value.parentPath.remove();
21
21
  }
22
- } else {
22
+ } else if (!value.isTemplateLiteral()) {
23
23
  value.replaceWith(
24
24
  (0, _withPreviousLocation.default)(
25
25
  _compiler.types.callExpression(
@@ -1,6 +1,11 @@
1
1
  "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.default = _default;var _babelUtils = require("@marko/babel-utils");
2
+
3
+
4
+
5
+
2
6
  var _compiler = require("@marko/compiler");
3
7
  var _attr = _interopRequireDefault(require("marko/src/runtime/html/helpers/attr"));
8
+ var _escapeQuotes = require("marko/src/runtime/html/helpers/escape-quotes");
4
9
 
5
10
  var _util = require("../util");
6
11
 
@@ -94,6 +99,32 @@ function _default(path, attrs) {
94
99
  }
95
100
 
96
101
  curString += (0, _attr.default)(name, computed);
102
+ } else if (value.type === "TemplateLiteral") {
103
+ curString += " " + name + '="';
104
+
105
+ for (let i = 0; i < value.expressions.length; i++) {
106
+ const quasi = value.quasis[i];
107
+ const expression = value.expressions[i];
108
+ curString += (0, _escapeQuotes.d)(quasi.value.cooked);
109
+ quasis.push(curString);
110
+ curString = "";
111
+ expressions.push(
112
+ _compiler.types.callExpression(
113
+ (0, _babelUtils.importNamed)(
114
+ file,
115
+ "marko/src/runtime/html/helpers/escape-quotes.js",
116
+ "d",
117
+ "marko_escape_double_quotes"
118
+ ),
119
+ [expression]
120
+ )
121
+ );
122
+ }
123
+
124
+ curString +=
125
+ (0, _escapeQuotes.d)(
126
+ value.quasis[value.expressions.length].value.cooked
127
+ ) + '"';
97
128
  } else {
98
129
  quasis.push(curString);
99
130
  curString = "";
@@ -3,8 +3,11 @@
3
3
 
4
4
 
5
5
 
6
+ var _compiler = require("@marko/compiler");
6
7
 
7
8
  var _htmlOutWrite = _interopRequireDefault(require("../../util/html-out-write"));
9
+ var _vdomOutWrite = _interopRequireDefault(require("../../util/vdom-out-write"));
10
+ var _withPreviousLocation = _interopRequireDefault(require("../../util/with-previous-location"));
8
11
 
9
12
  function enter(path) {
10
13
  (0, _babelUtils.assertNoArgs)(path);
@@ -12,8 +15,38 @@ function enter(path) {
12
15
  (0, _babelUtils.assertNoAttributes)(path);
13
16
 
14
17
  if (path.hub.file.markoOpts.output === "html") {
15
- path.replaceWithMultiple([(0, _htmlOutWrite.default)`<!--`, ...path.node.body.body, (0, _htmlOutWrite.default)`-->`]);
18
+ path.replaceWithMultiple([
19
+ (0, _htmlOutWrite.default)`<!--`,
20
+ ...path.node.body.body,
21
+ (0, _htmlOutWrite.default)`-->`]
22
+ );
16
23
  } else {
17
- path.remove();
24
+ const templateQuasis = [];
25
+ const templateExpressions = [];
26
+ let currentQuasi = "";
27
+ for (const child of path.node.body.body) {
28
+ if (_compiler.types.isMarkoText(child)) {
29
+ currentQuasi += child.value;
30
+ } else if (_compiler.types.isMarkoPlaceholder(child)) {
31
+ templateQuasis.push(_compiler.types.templateElement({ raw: currentQuasi }));
32
+ templateExpressions.push(child.value);
33
+ currentQuasi = "";
34
+ }
35
+ }
36
+
37
+ let value;
38
+ if (templateExpressions.length === 0) {
39
+ value = _compiler.types.stringLiteral(currentQuasi);
40
+ } else {
41
+ templateQuasis.push(_compiler.types.templateElement({ raw: currentQuasi }));
42
+ value = _compiler.types.templateLiteral(templateQuasis, templateExpressions);
43
+ }
44
+
45
+ path.replaceWith(
46
+ (0, _withPreviousLocation.default)(
47
+ (0, _vdomOutWrite.default)("comment", value, path.hub.file._componentInstanceIdentifier),
48
+ path.node
49
+ )
50
+ );
18
51
  }
19
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/translator-default",
3
- "version": "6.0.10",
3
+ "version": "6.0.12",
4
4
  "description": "Translates Marko templates to the default Marko runtime.",
5
5
  "keywords": [
6
6
  "babel",
@@ -34,8 +34,8 @@
34
34
  "self-closing-tags": "^1.0.1"
35
35
  },
36
36
  "devDependencies": {
37
- "@marko/compiler": "^5.37.8",
38
- "marko": "^5.35.12"
37
+ "@marko/compiler": "^5.37.10",
38
+ "marko": "^5.35.15"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "@marko/compiler": "^5.16.1",