⚡ zeno-rs
High-Performance Laravel Blade Template Engine & ZenoLang Scripting Engine for Rust
Write familiar
@if,@foreach,@extends,{{ $var }}, and<x-component>Blade templates — executed directly at native Rust speed.
Overview · vs Tera · Quickstart · Native Plugins · Blade Reference · Components · Hot Reload
🌟 Overview
zeno-rs brings the developer experience of Laravel Blade templating to the Rust ecosystem. If you are familiar with Blade syntax, you can use your existing .blade.zl views seamlessly in Rust web services (such as Axum, Actix, or Tower) without learning a new template syntax.
Key Features
- 100% Blade Compatible: Supports
@extends,@section,@yield,@include,@forelse,@csrf,@method, and<x-component>tags. - Smart Hot Reload: Per-file
mtimecache invalidation so template edits take effect instantly in development without restarting the server. - Embedded ZenoLang Execution: Full scripting engine with 50+ built-in slots for string manipulation, math calculations, arrays, and maps.
- Native Dynamic Plugin System: Load compiled Rust shared libraries (
.so,.dylib,.dll) at runtime via FFI without recompiling the core engine. - Lightweight Footprint: Single binary deployment with minimal memory consumption (~2-5 MB under load).
🆚 zeno-blade vs Tera
Tera is a popular template engine in the Rust ecosystem inspired by Jinja2/Django. zeno-blade is designed specifically for teams that prefer Laravel Blade syntax or require granular per-file hot reloading.
Technical & DX Comparison
| Feature | zeno-blade | Tera | Notes |
|---|---|---|---|
| 🔥 Per-file Hot Reload | ✅ | ❌ | zeno-blade re-parses only modified files on save |
| 🎨 Laravel Blade Syntax | ✅ | ❌ | Direct support for @extends, @section, {{ $var }} |
| 🧩 HTML Components () | ✅ | ❌ | Native component encapsulation with slots |
| 📐 Layout Inheritance | ✅ | ✅ | Both support layout inheritance & block yields |
🔁 Empty Loop Fallback (@forelse) |
✅ | ❌ | Direct support for @forelse ... @empty ... @endforelse |
🎯 Conditional Classes (@class) |
✅ | ❌ | Directive for dynamic CSS class lists |
🔐 Form Directives (@csrf, @method) |
✅ | ❌ | Built-in form helpers |
🔌 Native C-ABI Dynamic Plugins (.so) |
✅ | ❌ | Load .so/.dylib Rust extensions at runtime |
| 🧰 Built-in Utility Suite | ✅ | ❌ | 50+ built-in math, string, array, map slots |
| 📄 OpenAPI / Swagger UI Integration | ✅ | ❌ | Bundled zeno-apidoc crate |
🔥 Workspace Architecture
zeno-rs is organized as a modular workspace:
zeno-rs/
├── crates/
│ ├── zenocore/ # 🔩 Core engine: lexer, parser, executor, scope, dynamic plugins
│ ├── zeno-blade/ # 🎨 Blade engine — transpiles .blade.zl → AST → HTML
│ ├── zeno-std/ # 🧰 Standard library: math, date, string, money
│ ├── zeno-apidoc/ # 📄 OpenAPI 3.0 spec + Swagger UI generator
│ ├── zenoengine/ # 📦 Batteries-included facade (recommended starting point)
│ └── zeno-plugin-example/ # 🔌 Example native C-ABI Rust dynamic plugin (.so)
└── examples/
└── web_server/ # 🚀 Axum web server integration example
Templates are 100% portable between Go (
zeno-go) and Rust (zeno-rs) backends.
⚡ Quickstart
1. Add Dependencies
Add zenoengine to your Cargo.toml:
[]
= "0.2" # batteries-included facade
= "0.2" # core engine + plugin system
= "0.2" # or just the Blade engine
2. Render Blade Templates in Rust
use ;
use ;
use parse_string;
let engine = new_engine;
register_blade_slots;
let mut ctx = new;
ctx.set;
let scope = new;
scope.set;
scope.set;
scope.set;
let node = parse_string.unwrap;
engine.execute.unwrap;
let html = ctx..unwrap;
println!; // Rendered HTML output
3. Write Your Blade Template (resources/views/dashboard.blade.zl)
@extends('layouts.app')
@section('content')
Welcome back, {{ $user }}!
@if($role == 'admin')
Admin
@endif
@forelse($posts as $post)
{{ $post }}
@empty
No recent posts.
@endforelse
@endsection
🔌 Native Rust Dynamic Plugins (.so / .dylib / .dll)
zeno-rs includes a Native Dynamic Plugin System. You can compile custom Rust code into a shared library (.so, .dylib, .dll) and load it dynamically into ZenoCore at runtime.
1. Write Plugin Crate (cdylib)
// Cargo.toml -> [lib] crate-type = ["cdylib"]
use ;
use Arc;
pub extern "C"
2. Load & Execute in ZenoLang Script (.zl)
# Load shared library dynamically at runtime
plugin.load: './plugins/libcustom_plugin.so'
# Execute custom slot registered by the plugin
custom.sha256: 'secret data'
log: $hash
🎨 Blade Directives
| Directive | Description |
|---|---|
{{ $var }} |
Escaped output |
{!! $raw !!} |
Unescaped raw HTML output |
@if / @elseif / @else / @endif |
Conditional branches |
@foreach / @endforeach |
Array/list iteration |
@forelse / @empty / @endforelse |
Iteration with empty fallback block |
@extends('layout') |
Extend base template layout |
@section / @endsection |
Define content section |
@yield('name') |
Render content section in layout |
@include('partial') |
Include partial template |
@push('stack') / @stack('stack') |
Push to named stack |
@class(['cls' => $cond]) |
Dynamic CSS class builder |
@csrf / @method('PUT') |
Form helpers |
{{-- comment --}} |
Server-side comment |
🧩 HTML Components
Encapsulate UI into reusable Blade components (<x-component>):
Component definition — resources/views/components/alert.blade.zl:
$is_danger, 'alert-success' => $is_success])>
{{ $header }}
{{ $slot }}
Usage:
Notice
Your session will expire shortly.
⚙️ Template Loading & Hot Reload
In development, zeno-blade checks the mtime timestamp of template files on each request. Only files that have been modified are re-parsed into AST. All unchanged templates remain cached in memory, providing instant feedback without restarting the server.
🧰 Built-in Slots Suite
ZenoCore includes 50+ built-in slots:
- Logic:
if(&&,||,==,!=,>,<,>=,<=),for,while,try,var - String:
string.trim,upper,lower,split,replace,contains,starts_with,ends_with,len,concat,substr,format - Math:
math.add,sub,mul,div,mod,pow,sqrt,abs,ceil,floor,round,min,max,clamp,random - Collections:
array.push,pop,shift,unshift,slice,reverse,sort,unique,contains,map.set,get,delete,merge,keys,values,has,entries - Utilities:
log,print,coalesce,cast.to_int/float/string/bool,include,util.datetime,util.timestamp,util.uuid,util.env
🏗️ Build & Test
# Build plugin example
# Run workspace unit tests
Requirements: Rust 1.85+ (Edition 2024)
📝 License
Apache 2.0 © NextCore
Laravel Blade DX powered by Rust Performance.
⭐ Star zeno-rs on GitHub if you find this project useful!