# oxblade

> Laravel's Blade templates with Rust-style expressions.

- Package: oxblade (Laravel for Rust, alpha), crates: `oxblade`, `oxblade-laravel`, `oxblade-macros`, `oxblade-mail`, `oxblade-cli`
- Maintenance: active; Latest release: 0.2.0 (2026-12-05); Framework: laravel-rust 0.2.x; MSRV: Rust 1.99 or later; Licence: MIT
- Links: [Repository](https://github.com/bowerbird-si/oxblade), [crates.io](https://crates.io/crates/oxblade/0.2.0), [docs.rs](https://docs.rs/oxblade/0.2.0), [Changelog](https://oss.bowerbird.si/oxblade/docs/changelog/), [Contributing](https://github.com/bowerbird-si/oxblade/blob/c7fab7e68e7ad4df560796ee140e438944d26598/CONTRIBUTING.md), [Security policy](https://github.com/bowerbird-si/oxblade/blob/c7fab7e68e7ad4df560796ee140e438944d26598/SECURITY.md)
- Based on: [Laravel Blade](https://github.com/illuminate/view): The template language this package implements: Blade's markup, directives and rendered HTML (illuminate/view, MIT).
- Community package, not affiliated with Laravel.
- HTML version: https://oss.bowerbird.si/oxblade/
- Documentation: https://oss.bowerbird.si/oxblade/docs.md

Oxblade matches Laravel 13.39.0 byte for byte on all 977 paired conformance cases in CI. Separate suites check pagination views, Markdown mail and translations. Templates use Rust-style expressions such as `user.name`, `items.len()` and `|c| c.score >= 80`.

```shell
cargo add oxblade@0.2 serde_json@1
```

- **Laravel is the oracle.** The conformance suite compares output bytes from paired templates rendered by oxblade and Laravel 13.39.0.
- **Blade, with Rust expressions.** Templates use Blade markup and directives. Conditions require `bool` and conversions are explicit. Use the `php::` functions for PHP behaviour.
- **Components with typed props.** Anonymous, class and inline components, named slots, `@aware` and attribute bags, with props declared as `@props(tone: String = 'info')`.
- **Laravel for Rust integration.** `oxblade-laravel` registers the engine and brings `route()`, `asset()`, `@auth`, `@can`, `@csrf`, translations, pagination views and Markdown mail.
- **Checked in CI.** `blade:check` validates templates against the Rust view models that render them.
- **Migrate from PHP Blade.** `oxblade migrate` converts `.blade.php` views and marks what needs a person with `TODO` comments; `oxblade lang` converts PHP language files.
- **Bounded renders.** Render limits cover output size, loop iterations, collection expansion and nesting depth. The Laravel adapter exposes configuration through an explicit allow-list.

### Blade and oxblade side by side

Both templates iterate through posts and display a fallback when the list is empty.

```blade
{{-- PHP Blade --}}
@foreach ($posts as $post)
    <x-card :title="$post->title">{{ $post->excerpt }}</x-card>
@endforeach
@if ($posts->isEmpty())<p>No posts yet.</p>@endif

{{-- oxblade --}}
@foreach (post in posts)
    <x-card :title="post.title">{{ post.excerpt }}</x-card>
@endforeach
@if (posts.is_empty())<p>No posts yet.</p>@endif
```

### Render a view

Views can come from memory, as here, or from `.blade.html` files with `FilesystemLoader`.

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

let views = MemoryLoader::new()
    .view("layouts.app", "<main>@yield('content')</main>")
    .view("hello", "@extends('layouts.app')\n@section('content')Hello, {{ name }}!@endsection");

let env = Environment::builder(views).build();
let html = env.render_json("hello", &json!({ "name": "<Ada>" }))?;
assert_eq!(html, "<main>Hello, &lt;Ada&gt;!</main>");
```
