@mulanjs/mulanjs 1.0.1-dev.20260310065102 → 1.0.1-dev.20260310071649
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/README.md +5 -2
- package/dist/compiler/ast-parser.js +16 -1
- package/package.json +1 -1
- package/src/compiler/ast-parser.ts +17 -1
package/README.md
CHANGED
|
@@ -67,7 +67,7 @@ Built-in support for `<style lang="scss">`. No config required. Just design.
|
|
|
67
67
|
|
|
68
68
|
MulanJS components (`.mujs`) allow you to write powerful, reactive UI with minimal boilerplate.
|
|
69
69
|
|
|
70
|
-
```
|
|
70
|
+
```javascript
|
|
71
71
|
<mu>
|
|
72
72
|
// The <mu> tag is the new, powerful replacement for <script setup lang="ts">
|
|
73
73
|
import { muState } from 'mulanjs';
|
|
@@ -79,6 +79,8 @@ debugClick() →
|
|
|
79
79
|
console.log('Button clicked! Current count:', state.count);
|
|
80
80
|
state.count++;
|
|
81
81
|
</mu>
|
|
82
|
+
```
|
|
83
|
+
```html
|
|
82
84
|
|
|
83
85
|
<mu-template>
|
|
84
86
|
<div class="page">
|
|
@@ -96,7 +98,8 @@ debugClick() →
|
|
|
96
98
|
</div>
|
|
97
99
|
</div>
|
|
98
100
|
</mu-template>
|
|
99
|
-
|
|
101
|
+
```
|
|
102
|
+
```css
|
|
100
103
|
<style scoped>
|
|
101
104
|
.page { padding: 60px 20px; text-align: center; }
|
|
102
105
|
h1 {
|
|
@@ -319,7 +319,22 @@ function parseTag(content) {
|
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
321
|
else if (key) {
|
|
322
|
-
|
|
322
|
+
let finalKey = key;
|
|
323
|
+
let finalValue = value;
|
|
324
|
+
// Alias: mu-bind:attr="val" or :attr="val" -> translates to native MulanJS attr="${val}"
|
|
325
|
+
if (key.startsWith('mu-bind:')) {
|
|
326
|
+
finalKey = key.slice(8);
|
|
327
|
+
finalValue = `\${${value}}`;
|
|
328
|
+
}
|
|
329
|
+
else if (key.startsWith(':')) {
|
|
330
|
+
finalKey = key.slice(1);
|
|
331
|
+
finalValue = `\${${value}}`;
|
|
332
|
+
}
|
|
333
|
+
// Alias: mu-on:event="func()" -> translates to native @event
|
|
334
|
+
else if (key.startsWith('mu-on:')) {
|
|
335
|
+
finalKey = '@' + key.slice(6);
|
|
336
|
+
}
|
|
337
|
+
props[finalKey] = finalValue;
|
|
323
338
|
}
|
|
324
339
|
}
|
|
325
340
|
return { tag, props, directives };
|
package/package.json
CHANGED
|
@@ -369,7 +369,23 @@ export function parseTag(content: string) {
|
|
|
369
369
|
directives.vFor = { item: item.trim(), list: list.trim() };
|
|
370
370
|
}
|
|
371
371
|
} else if (key) {
|
|
372
|
-
|
|
372
|
+
let finalKey = key;
|
|
373
|
+
let finalValue = value;
|
|
374
|
+
|
|
375
|
+
// Alias: mu-bind:attr="val" or :attr="val" -> translates to native MulanJS attr="${val}"
|
|
376
|
+
if (key.startsWith('mu-bind:')) {
|
|
377
|
+
finalKey = key.slice(8);
|
|
378
|
+
finalValue = `\${${value}}`;
|
|
379
|
+
} else if (key.startsWith(':')) {
|
|
380
|
+
finalKey = key.slice(1);
|
|
381
|
+
finalValue = `\${${value}}`;
|
|
382
|
+
}
|
|
383
|
+
// Alias: mu-on:event="func()" -> translates to native @event
|
|
384
|
+
else if (key.startsWith('mu-on:')) {
|
|
385
|
+
finalKey = '@' + key.slice(6);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
props[finalKey] = finalValue;
|
|
373
389
|
}
|
|
374
390
|
}
|
|
375
391
|
|