feat: add support for running ejs

This commit is contained in:
Hatem Hosny committed 2025-01-05 14:57:12 +02:00
1 parent 5c28df9672
commit d878467327
2 files changed
+25 -1

No files matched your search

+3 -1
View File
@@ -12,6 +12,7 @@ intro:
EJS(Embedded JavaScript) is a simple templating language that lets you generate HTML markup with plain JavaScript.
plugins:
- copyCode
- runCode
---
<!-- NOTE: EJS does not have Prettier support, so manually format and add a prettier-ignore above broken code blocks -->
@@ -58,10 +59,11 @@ Pass EJS a template string and some data.
### Browser Support
```html
<script src="ejs.js"></script>
<script src="https://unpkg.com/ejs"></script>
<script>
let people = ["geddy", "neil", "alex"];
let html = ejs.render('<%= people.join(", "); %>', { people: people });
console.log(html);
</script>
```
+22
View File
@@ -185,6 +185,28 @@
}
}
if (language === 'html' && document.querySelector('h1').textContent.includes('EJS')) {
config = {
...baseConfig,
markup: {
language: 'ejs',
content,
},
script: {
language: 'javascript',
content: "window.livecodes.templateData = {\n userLoggedIn: false,\n user: { username: 'geddy', email: 'geddy@example.com' },\n users: [\n { username: 'geddy', email: 'geddy@example.com' },\n { username: 'neil', email: 'neil@example.com' },\n { username: 'alex', email: 'alex@example.com' },\n ],\n};\n",
},
tools: {
status: 'open',
},
customSettings: {
"template": {
"prerender": false,
},
},
}
}
if (['php'].includes(language)) {
config = {
...baseConfig,