oxblade 0.1.0

Blade templates for Laravel for Rust: Blade's markup and directives, Laravel's helpers, Rust's expressions. Community package, not affiliated with Laravel.
Documentation
//! Renders a page that extends a layout, loops over a list and uses a component.
#![allow(missing_docs, clippy::unwrap_used, clippy::expect_used)] // Test, bench and example code may unwrap.

use oxblade::{engine::Environment, loader::MemoryLoader};
use serde_json::json;

fn main() -> Result<(), oxblade::error::Error> {
    let views = MemoryLoader::new()
        .view(
            "layouts.app",
            "<title>@yield('title')</title>\n<main>@yield('content')</main>\n",
        )
        .view(
            "components.badge",
            "@props(tone: String = 'info')\n<span class=\"badge badge-{{ tone }}\">{{ slot }}</span>",
        )
        .view(
            "books",
            "@extends('layouts.app')\n\
             @section('title', 'Books')\n\
             @section('content')\n\
             @foreach (book in books)\n\
             <p>{{ book.title }}@if (book.year < 1900) <x-badge tone=\"old\">classic</x-badge>@endif</p>\n\
             @endforeach\n\
             @endsection\n",
        );

    let env = Environment::builder(views).build();
    let html = env.render_json(
        "books",
        &json!({
            "books": [
                { "title": "Middlemarch", "year": 1871 },
                { "title": "Tom & Jerry's <Guide>", "year": 2026 },
            ]
        }),
    )?;
    print!("{html}");
    Ok(())
}