Skip to content
/ van Public

A Vue-style server-side template engine for any framework.

License

Notifications You must be signed in to change notification settings

vanengine/van

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Van

Language-agnostic template engine with Vue SFC syntax
Server-side HTML rendering · Signal-based client interactivity · WASM-powered

License Release Crates.io Platforms

Features · Installation · Usage · Example · Architecture · Build

🌐 English · 简体中文


Features

  • Vue SFC Syntax — Write templates with familiar <template>, <script setup>, <style scoped> blocks
  • Zero Node.js Dependency — Core written in Rust, compiles to WASM for backend integration
  • Signal-based Reactivity — Lightweight client-side interactivity with direct DOM updates (~4KB runtime, no virtual DOM)
  • Framework-agnostic — WASM compiler integrates with any backend via JSON stdin/stdout protocol
  • Cross-platform — Pre-built WASM + native binaries for Linux x64/ARM64, macOS x64/ARM64, and Windows x64

Installation

One-line install (Linux / macOS):

curl -fsSL https://raw.githubusercontent.com/vanengine/van/main/install.sh | sh

Manual download: grab the latest van-cli-* binary from GitHub Releases and place it in your PATH.

Usage

van init my-project        # Scaffold a new Van project
van dev                    # Start dev server with hot reload
van generate               # Static site generation

Framework Integration

Van compiles .van files to HTML via a WASM binary — integrate with any backend:

See WASM Integration below for the raw JSON protocol.

Example

<template>
  <h1>{{ title }}</h1>
  <button @click="count++">Clicked {{ count }} times</button>
</template>

<script setup>
let count = 0
</script>

<style scoped>
h1 { color: steelblue; }
</style>

Server-side {{ title }} is interpolated by the host framework; count becomes a reactive signal with automatic DOM updates on the client.

Architecture

.van file → [van-parser] → VanBlock
                              ├── [van-compiler] → Server HTML with {{ expr }}
                              └── [van-signal-gen] → Signal-based JS (direct DOM ops)

Core Engine (crates/)

Crate Purpose
van-parser Hand-written recursive descent parser for .van files
van-compiler Orchestrates server HTML + client JS compilation
van-compiler-wasi WASM entry point (JSON stdin/stdout protocol)
van-signal-gen <script setup> → signal-based direct DOM JS

CLI Toolchain (crates/van-cli/)

Crate Purpose
van-cli CLI binary (van init, van dev, van generate)
van-context Project context and configuration
van-dev Dev server with hot reload
van-init Project scaffolding

Build from Source

Prerequisites: Rust toolchain (1.70+)

# Build all crates
cargo build --release

# Build CLI binary
cargo build --release -p van-cli

# Build WASM binary (for framework integration)
cargo build --target wasm32-wasip1 -p van-compiler-wasi --release

# Run tests
cargo test
WASM Integration

The WASM compiler receives JSON via stdin and returns compiled HTML:

// Input
{ "entry_path": "pages/index.van", "files": { ... }, "mock_data_json": "..." }

// Output
{ "ok": true, "html": "<h1>{{ title }}</h1>..." }

Two execution modes:

  • Single-shot (default) — reads stdin, compiles once, writes response
  • Daemon (--daemon) — JSON Lines protocol, stays alive until stdin EOF

Host frameworks perform a second pass to interpolate {{ expr }} with server-side model data.

Related

License

MIT

About

A Vue-style server-side template engine for any framework.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 2

  •  
  •