Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

Documentation

Complete documentation for @neabyte/dve. For install steps and a quick overview, see the project README.

Guides

  • Engine - The DVE class: compile, render, stream, and validate templates.
  • Syntax - Template tags: variables, raw output, comments, includes, layouts, conditionals, and loops.
  • Expressions - The sandboxed expression language: operators, literals, and member access.
  • Editor Extension - Highlighting and snippets for .dve files.

Quick Reference

A cheat sheet of the public API. See Engine for full signatures and behaviour.

Method Returns Purpose
new DVE(options?) DVE Create an engine instance
compile(text, name?) CompileResult Parse a template into a reusable AST
render(compiled, data?, name?) string Render a compiled template to a string
renderStream(compiled, data?, name?) ReadableStream<Uint8Array> Stream a compiled template
renderString(text, data?, name?) string Compile then render in one call
renderStringStream(text, data?, name?) ReadableStream<Uint8Array> Compile then stream in one call
validate(compiled, name?) void Statically check a template, throwing on error

Tag Reference

A cheat sheet of the template tags. See Syntax for examples and details.

Tag Meaning
{{ value }} Escaped output
{{{ value }}} Raw (unescaped) output
{{!-- comment --}} Comment, never rendered
{{> path}} Include another template
{{< layout}} ... {{/}} Extend a layout
{{#block name}} ... {{/block}} Fill a layout slot
{{#slot name}} ... {{/slot}} Define a layout placeholder
{{#if x}} ... {{else}} ... {{/if}} Conditional
{{#each xs as x}} ... {{/each}} Loop over an array
{{~ ... ~}} Trim surrounding whitespace