Skip to content

Repository files navigation

DVE (Deserve View Engine)

Tiny zero-dependency HTML template engine for every JavaScript runtime

NodeDenoBunCDN

Module type: Deno/ESMnpm versionJSRLicense

What is DVE?

DVE started life as the view engine inside Deserve. It was pulled out into its own package so the rendering layer is easier to maintain, lighter to depend on, and free to grow on its own. As a standalone library it now fits far more use cases than a single framework, from full server-rendered apps to edge functions, static builds, email templates, and anywhere else you need safe HTML from data.

DVE turns your HTML templates into finished pages, fast and safely. You write familiar {{ value }} tags, loops, conditionals, and reusable layouts. DVE fills them with your data and hands back ready-to-serve HTML, either as a string or a live stream. It ships as a single tiny package with no dependencies, so the same code runs on your server, at the edge, or straight from a CDN in the browser. And because user data is escaped by default and templates can't run arbitrary code, you get safe-by-default rendering without thinking about it.

If you want simple, predictable HTML rendering that just works everywhere, DVE is for you.

Installation

Note

Prerequisites: For Deno (install from deno.com). For npm use Node.js (e.g. nodejs.org).

Deno (JSR):

deno add jsr:@neabyte/dve

npm:

npm install @neabyte/dve

CDN (jsDelivr/unpkg/esm.sh):

<scripttype="module">importDVEfrom'https://cdn.jsdelivr.net/npm/@neabyte/dve/dist/index.mjs'</script>

Or via esm.sh:

<scripttype="module">importDVEfrom'https://esm.sh/@neabyte/dve'</script>

Or via importmap:

<scripttype="importmap">{"imports": {"@neabyte/dve": "https://cdn.jsdelivr.net/npm/@neabyte/dve/dist/index.mjs"}}</script><scripttype="module">importDVEfrom'@neabyte/dve'</script>

Quick Start

importDVEfrom'@neabyte/dve'// Create one engine and reuse it across rendersconstdve=newDVE()// Render straight from template text in one callconsthtml=dve.renderString('Hello {{ user?.name ?? "Guest" }}.',{user: {name: 'Ada'}})// html is 'Hello Ada.'// Compile once, then reuse the compiled template for many rendersconstcompiled=dve.compile('{{#each items as item}}{{ item }},{{/each}}')dve.render(compiled,{items: [1,2,3]})// returns '1,2,3,'

Documentation

  • Engine - The DVE class: options, methods, events, and validation.
  • Syntax - Template tags: variables, raw output, includes, layouts, conditionals, and loops.
  • Expressions - The sandboxed expression language: operators, literals, and member access.
  • Editor Extension - Syntax highlighting and snippets for .dve files in VS Code, Cursor, and Trae.

The full index lives in docs/README.md.

Build

npm build (bundles to dist/):

npm run build

Testing

Type check - format, lint, and type-check:

deno task check

Unit tests - run all tests:

deno task test
  • Tests live under tests/ (dve, eval, expression, helper, parser, and tokenizer tests).

Benchmarks

Performance benchmarks - run with deno bench:

deno task bench

License

This project is licensed under the MIT license. See the LICENSE file for details.

About

Tiny zero-dependency HTML template engine that renders data into safe HTML as a string or stream on any JavaScript runtime.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Contributors

Languages