feat: replace all matches
This commit is contained in:
parent
03bfab0163
commit
6d6921aa64
3 changed files with 13 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
|||
//https://nitro.unjs.io/config
|
||||
export default defineNitroConfig({
|
||||
preset: "node",
|
||||
preset: "vercel",
|
||||
devServer: {
|
||||
watch: ["./src/pages", "./src/components"],
|
||||
},
|
||||
|
|
|
@ -67,5 +67,14 @@ function doSetUp(html: string) {
|
|||
Object.assign(setupMap, new evalStore());
|
||||
});
|
||||
|
||||
return html.replace("{{name}}", setupMap["name"]);
|
||||
const regex = /{{(.*?)}}/g;
|
||||
var match;
|
||||
|
||||
let matches = [];
|
||||
while ((match = regex.exec(html)) != null) {
|
||||
console.log(match[0], match[1]);
|
||||
html = html.replace(match[0], setupMap[match[1]]);
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<title>Hello Nitro</title>
|
||||
<script server:setup>
|
||||
const name = "AYOs";
|
||||
return { name }; // TODO: this is illegal! figure out a way to build an object in the route intercept
|
||||
return { name, greeting: "hey" }; // TODO: this is illegal! figure out a way to build an object in the route intercept
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -14,7 +14,7 @@
|
|||
<div>
|
||||
<hello-world name="{{name}}"></hello-world>
|
||||
</div>
|
||||
<span>some text</span>
|
||||
<span>some text: {{greeting}}</span>
|
||||
<clickable-text></clickable-text>
|
||||
<script>
|
||||
const helloWorld = document.querySelector("hello-world");
|
||||
|
|
Loading…
Reference in a new issue