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

oxblade

CI status: alpha crates.io docs.rs MSRV 1.99 Licence: MIT

Oxblade matches Laravel 13's HTML byte for byte on all 971 paired conformance cases in CI. The expected output comes from Laravel 13.39.0 itself. Separate suites check 181 pagination fixtures, six Markdown emails in HTML and text, and 4,523 translation records. See the parity matrix for documented differences. Templates use Rust-style expressions such as user.name, items.len() and |c| c.score >= 80.

Quick start

[dependencies]
oxblade = "0.1"
serde_json = "1"
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(())
}

It prints:

<title>Books</title>
<main><p>Middlemarch <span class="badge badge-old">classic</span></p>
<p>Tom &amp; Jerry&#039;s &lt;Guide&gt;</p>
</main>

The same program is crates/oxblade/examples/quickstart.rs; CI builds and runs it. In a Laravel for Rust app, oxblade-laravel registers the engine and views load from resources/views; see the guide.

Blade, with Rust expressions

Templates use Blade markup and directives with Rust-style expressions.

PHP Blade oxblade
{{ $user->name }} {{ user.name }}
@foreach ($posts as $post) @foreach (post in posts)
@if ($posts->isEmpty()) @if (posts.is_empty())
{{ $items->count() }} {{ items.len() }}
<x-alert :type="$level" /> <x-alert :type="level" />
@php … @endphp @code … @endcode, with Rust statements
{{ number_format($price, 2) }} {{ number_format(price, 2) }}

Conditions must be bool, nothing converts implicitly, and integer division is Rust's. Where a template needs PHP's exact behaviour, the php:: functions from laravel-rust-format provide it. Laravel's collection, string, number and date helpers are available under their Laravel names.

What it covers

  • Laravel 13's Blade: its directives, template inheritance, components (anonymous, class and inline), slots, @aware, stacks, @once, @verbatim, @json, @js, custom directives and conditions, view composers, pagination views and the mail Markdown components. @fonts waits on the framework. The parity matrix lists every feature and how oxblade handles it.
  • Translations: __(), trans(), trans_choice(), @lang and @choice, with Laravel's replacements and plural rules for 280 locales. The adapter loads the app's lang/ directory and uses the request's locale.
  • Laravel for Rust integration in oxblade-laravel: a view engine and service provider, route(), url(), asset(), @auth/@can, CSRF and method fields, and blade:check.
  • Type checking: check validates templates against the Rust view models that render them, in CI.
  • Migration from PHP Blade: the oxblade command (oxblade-cli) converts .blade.php views, marks what needs a person with TODO comments, replays later PHP changes as diffs, and converts PHP language files with oxblade lang.
  • Limits: output size, loop iterations, collection expansion and nesting depth are bounded per core render. The core expression language provides no direct file or environment access. The Laravel adapter's config(key) allows app.name, app.env, app.url, app.debug and keys the app explicitly exposes.

How output is checked

Each case in conformance/cases pairs a PHP Blade template with an oxblade template and shared input data. CI reruns the PHP oracle to check the stored output, then compares oxblade's render with that output. Case notes explain any deliberate adjustments to the pair.

353 tests · 6 fuzz targets (counted by kit readme)

Installation and configuration

See the guide.

Compatibility

Crate Framework MSRV
oxblade none 1.99
oxblade-macros none 1.99
oxblade-laravel laravel-rust 0.2 1.99
oxblade-cli none 1.99
oxblade-mail none 1.99

The adapter requires laravel-rust 0.2.0 or later within the 0.2 series. The lockfile and CI tests use 0.2.0.

Contributing

Issues and pull requests are welcome, of any size: bug reports, failing test cases, docs fixes, new features. A template that renders differently from Laravel is the most useful bug report: send the .blade.php file, its data and both outputs. Contributions written with AI coding agents are welcome too; please say what you checked. Run scripts/kit ci before opening a pull request, and see CONTRIBUTING.md. If you aren't sure, open an issue first.

Credits

  • Laravel's Blade (MIT): the syntax, directives and behaviour, measured against Laravel itself. Laravel's pagination views and mail components and themes are adapted as files and keep Laravel's licence notice.
  • laravel-rust-format: Laravel's string, number and date helpers and the php:: functions.
  • rustblade (MIT OR Apache-2.0): ideas such as trusted HTML only in {!! !!}, format as Rust's format!, and migration with TODO markers.
  • blade-syntax (MIT OR Apache-2.0): lexing rules for Blade's edge cases.
  • MiniJinja: the speed baseline.

Status and licence

Version 0.1.0 is prepared as the first alpha release. Maintenance is active. See the MIT licence and upstream credits.

Community package, not affiliated with Laravel.