🏎️ JavaScript Hypertext Preprocessor.
Rendu is a lightweight toolkit for mixing HTML and JavaScript with a focus on simplicity, standards and progressive rendering.
Warning
This is an experimental PoC.
Using the rendu CLI, you can start a local web server to serve static files and render .html files as templates (powered by srvx).
Compile a template string into a render function.
Example:
Compile a template string into a render function code string.
Note: This function is for advanced use cases where you need the generated code as a string.
Check if a template string contains template syntax.
- Type: array
- Default: ["htmlspecialchars","setCookie","redirect","$REQUEST","$METHOD","$URL","$HEADERS","$COOKIES","$RESPONSE"]
Renders an HTML template to a Response object.
Example:
Rendu uses PHP-style tags to embed JavaScript within HTML templates:
Use <script server> to execute JavaScript on the server where it appears:
Use {{ expression }} for HTML-escaped output, or {{{ expression }}} or <?= expression ?> for unescaped (raw) output:
Use <? ... ?> for JavaScript control flow:
Use the echo() function for streaming content. Accepts: strings, functions, Promises, Response objects, or ReadableStreams:
Examples:
Access request context and global state:
- $REQUEST: The incoming Request object
- $METHOD: HTTP method (GET, POST, etc.)
- $URL: Request URL object
- $HEADERS: Request headers
- $RESPONSE: Response configuration object
- $COOKIES: Read-only object containing request cookies
Use setCookie() function to set cookies in the response:
Access cookies from the request using $COOKIES:
Use redirect() function to redirect the user:
The htmlspecialchars() function is available for escaping HTML content:
Tip
When using curly {{ }} syntax, htmlspecialchars will be automatically applied.
- Clone this repository
- Install the latest LTS version of Node.js
- Enable Corepack using corepack enable
- Install dependencies using pnpm install
- Run interactive tests using pnpm dev
Published under the MIT license.
.png)


