diff options
author | 2021-09-26 00:14:15 -0700 | |
---|---|---|
committer | 2021-09-26 00:14:15 -0700 | |
commit | 66ed7c1f30d1ba6569efa114c9d90ccac45fb86a (patch) | |
tree | 4ba9471f0e3dfe2e8785654757464de43937229d /examples/macros/mystery-box.tsx | |
parent | ff8393ce3264f1d40fc82aef428dbb8c766b2b6f (diff) | |
download | bun-66ed7c1f30d1ba6569efa114c9d90ccac45fb86a.tar.gz bun-66ed7c1f30d1ba6569efa114c9d90ccac45fb86a.tar.zst bun-66ed7c1f30d1ba6569efa114c9d90ccac45fb86a.zip |
Basic macro impl
Diffstat (limited to 'examples/macros/mystery-box.tsx')
-rw-r--r-- | examples/macros/mystery-box.tsx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/examples/macros/mystery-box.tsx b/examples/macros/mystery-box.tsx new file mode 100644 index 000000000..9e72ee1c0 --- /dev/null +++ b/examples/macros/mystery-box.tsx @@ -0,0 +1,15 @@ +// macro code: +export function mysteryBox(node) { + const dice = Math.round(Math.random() * 100); + if (dice < 25) { + return <number value={5} />; + } else if (dice < 50) { + return <true />; + } else if (dice < 75) { + return <false />; + } else if (dice < 90) { + return <string value="a string" />; + } else { + return <string value={"a very rare string " + dice.toString(10)} />; + } +} |