Skip to content

Commit 5de0470

Browse files
committed
refactor: remove mustache
1 parent 0b65acc commit 5de0470

File tree

4 files changed

+15
-23
lines changed

4 files changed

+15
-23
lines changed

package-lock.json

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"test:update-snapshots": "node --test --experimental-test-module-mocks --test-update-snapshots",
1717
"test:watch": "node --test --experimental-test-module-mocks --watch",
1818
"prepare": "husky",
19-
"run": "node bin/cli.mjs",
19+
"run": "node --inspect bin/cli.mjs ",
2020
"watch": "node --watch bin/cli.mjs"
2121
},
2222
"main": "./src/index.mjs",
@@ -60,7 +60,6 @@
6060
"hastscript": "^9.0.1",
6161
"lightningcss": "^1.30.1",
6262
"mdast-util-slice-markdown": "^2.0.1",
63-
"mustache": "^4.2.0",
6463
"preact": "^10.26.9",
6564
"preact-render-to-string": "^6.5.13",
6665
"reading-time": "^1.5.0",

src/generators/web/template.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
</head>
1919

2020
<body>
21-
<div id="root">{{{dehydrated}}}</div>
22-
<script>{{{javascript}}}</script>
23-
</body>
21+
<div id="root">{{dehydrated}}</div>
22+
2423

25-
</html>

src/generators/web/utils/processing.mjs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import HTMLMinifier from '@minify-html/node';
22
import { toJs, jsx } from 'estree-util-to-js';
3-
import Mustache from 'mustache';
43

54
import bundleCode from './bundle.mjs';
65

@@ -72,12 +71,18 @@ export async function processJSXEntry(
7271
const clientCode = buildClientProgram(code);
7372
const clientBundle = await bundleCode(clientCode);
7473

75-
// TODO(@avivkeller): Don't depend on Mustache
76-
const renderedHtml = Mustache.render(template, {
77-
title: `${entry.data.heading.data.name} | Node.js v${version} Documentation`,
78-
dehydrated,
79-
javascript: clientBundle.js,
80-
});
74+
const title = `${entry.data.heading.data.name} | Node.js v${version} Documentation`;
75+
76+
const scriptTag = `<script>${clientBundle.js}</script>`;
77+
78+
// Replace template placeholders with actual content
79+
const filledTemplate = template
80+
.replace('{{title}}', title)
81+
.replace('{{dehydrated}}', dehydrated ?? '');
82+
83+
const renderedHtml = `${filledTemplate}
84+
${scriptTag}
85+
</body></html>`;
8186

8287
// The input to `minify` must be a Buffer.
8388
const finalHTMLBuffer = HTMLMinifier.minify(Buffer.from(renderedHtml), {});

0 commit comments

Comments
 (0)