htmv 0.0.39 → 0.0.41
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.
- package/dist/compiler/parser.js +30 -24
- package/package.json +1 -1
package/dist/compiler/parser.js
CHANGED
|
@@ -75,7 +75,7 @@ export function parse(tokens) {
|
|
|
75
75
|
if (nextToken?.type === "arguments") {
|
|
76
76
|
nodes.push({
|
|
77
77
|
type: "text",
|
|
78
|
-
text: `<${tag}`,
|
|
78
|
+
text: `<${tag} `,
|
|
79
79
|
});
|
|
80
80
|
parseArgs(nextToken.value);
|
|
81
81
|
nodes.push({
|
|
@@ -103,31 +103,37 @@ export function parse(tokens) {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
return nodes;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
106
|
+
function parseArgs(_args) {
|
|
107
|
+
const args = _args.join(" ");
|
|
108
|
+
let textBuffer = "";
|
|
109
|
+
for (let i = 0; i < args.length; i++) {
|
|
110
|
+
const letter = args[i];
|
|
111
|
+
if (letter === "{") {
|
|
112
|
+
pushBuffer();
|
|
113
|
+
clearBuffer();
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (letter === "}") {
|
|
117
|
+
nodes.push({
|
|
118
|
+
type: "interpolation",
|
|
119
|
+
value: textBuffer,
|
|
120
|
+
});
|
|
121
|
+
clearBuffer();
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
textBuffer += letter;
|
|
114
125
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
value: textBuffer,
|
|
119
|
-
});
|
|
120
|
-
clearBuffer();
|
|
126
|
+
pushBuffer();
|
|
127
|
+
function clearBuffer() {
|
|
128
|
+
textBuffer = "";
|
|
121
129
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
text: textBuffer,
|
|
130
|
-
});
|
|
130
|
+
function pushBuffer() {
|
|
131
|
+
if (textBuffer.length > 0) {
|
|
132
|
+
nodes.push({
|
|
133
|
+
type: "text",
|
|
134
|
+
text: textBuffer,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
131
137
|
}
|
|
132
138
|
}
|
|
133
139
|
}
|