@marko/translator-default 6.0.11 → 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.
@@ -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([
|
18
|
+
path.replaceWithMultiple([
|
19
|
+
(0, _htmlOutWrite.default)`<!--`,
|
20
|
+
...path.node.body.body,
|
21
|
+
(0, _htmlOutWrite.default)`-->`]
|
22
|
+
);
|
16
23
|
} else {
|
17
|
-
|
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.
|
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.
|
38
|
-
"marko": "^5.35.
|
37
|
+
"@marko/compiler": "^5.37.10",
|
38
|
+
"marko": "^5.35.15"
|
39
39
|
},
|
40
40
|
"peerDependencies": {
|
41
41
|
"@marko/compiler": "^5.16.1",
|