Skip to content

NeaByteLab/DVE

DVE (Deserve View Engine)

Tiny zero-dependency HTML template engine for every JavaScript runtime

Node Deno Bun CDN

Module type: Deno/ESM npm version JSR License

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):

<script type="module">
  import DVE from 'https://cdn.jsdelivr.net/npm/@neabyte/dve/dist/index.mjs'
</script>

Or via esm.sh:

<script type="module">
  import DVE from 'https://esm.sh/@neabyte/dve'
</script>

Or via importmap:

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

Quick Start

import DVE from '@neabyte/dve'

// Create one engine and reuse it across renders
const dve = new DVE()

// Render straight from template text in one call
const html = dve.renderString('Hello {{ user?.name ?? "Guest" }}.', {
  user: { name: 'Ada' }
})
// html is 'Hello Ada.'

// Compile once, then reuse the compiled template for many renders
const compiled = 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).

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

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors