htmv 0.0.37 → 0.0.39

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.
@@ -73,10 +73,14 @@ export function parse(tokens) {
73
73
  }
74
74
  const nextToken = tokens[i]; //may be arguments token
75
75
  if (nextToken?.type === "arguments") {
76
- const args = nextToken.value.join(" ");
77
76
  nodes.push({
78
77
  type: "text",
79
- text: `<${tag} ${args}>`,
78
+ text: `<${tag}`,
79
+ });
80
+ parseArgs(nextToken.value);
81
+ nodes.push({
82
+ type: "text",
83
+ text: `>`,
80
84
  });
81
85
  i++;
82
86
  continue;
@@ -100,4 +104,31 @@ export function parse(tokens) {
100
104
  }
101
105
  return nodes;
102
106
  }
107
+ function parseArgs(args) {
108
+ let textBuffer = "";
109
+ for (let i = 0; i < args.length; i++) {
110
+ const letter = args[i];
111
+ if (letter === "{") {
112
+ clearBuffer();
113
+ continue;
114
+ }
115
+ if (letter === "}") {
116
+ tokens.push({
117
+ type: "interpolation",
118
+ value: textBuffer,
119
+ });
120
+ clearBuffer();
121
+ }
122
+ textBuffer += letter;
123
+ }
124
+ clearBuffer();
125
+ function clearBuffer() {
126
+ if (textBuffer.length > 0) {
127
+ tokens.push({
128
+ type: "text",
129
+ text: textBuffer,
130
+ });
131
+ }
132
+ }
133
+ }
103
134
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "htmv",
3
3
  "main": "dist/index.js",
4
4
  "type": "module",
5
- "version": "0.0.37",
5
+ "version": "0.0.39",
6
6
  "devDependencies": {
7
7
  "@biomejs/biome": "2.3.3",
8
8
  "@types/bun": "latest"