<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: A.Mahidwei</title>
    <description>The latest articles on DEV Community by A.Mahidwei (@flatduck).</description>
    <link>https://dev.to/flatduck</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1040587%2Fb983abf9-5a75-4d3f-b979-e1763fcd5b7b.png</url>
      <title>DEV Community: A.Mahidwei</title>
      <link>https://dev.to/flatduck</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/flatduck"/>
    <language>en</language>
    <item>
      <title>Sowrd: Blade-style template engine for Rust</title>
      <dc:creator>A.Mahidwei</dc:creator>
      <pubDate>Fri, 04 Dec 2026 18:47:35 +0000</pubDate>
      <link>https://dev.to/flatduck/sowrd-blade-style-template-engine-for-rust-3hll</link>
      <guid>https://dev.to/flatduck/sowrd-blade-style-template-engine-for-rust-3hll</guid>
      <description>&lt;p&gt;I come from the Laravel side, and when I started writing server-rendered pages in Rust, the thing I missed most was Blade. Not the framework around it, just the way a template reads: &lt;code&gt;@foreach&lt;/code&gt;, layouts, &lt;code&gt;&amp;lt;x-button&amp;gt;&lt;/code&gt; components. So I built a small engine that gives me that, and I just published it.&lt;/p&gt;

&lt;p&gt;It's called &lt;strong&gt;Sword&lt;/strong&gt;. Templates are &lt;code&gt;.sword.html&lt;/code&gt; files, and they get translated to &lt;a href="https://github.com/mitsuhiko/minijinja" rel="noopener noreferrer"&gt;MiniJinja&lt;/a&gt; under the hood, so you get a mature runtime without writing Jinja yourself.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it looks like
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="n"&gt;rustysan_sword&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;Sword&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="n"&gt;serde_json&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Sword&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;default&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render_source&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;"greeting"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Hello {{ name }}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nf"&gt;json!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;Ada&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;assert_eq!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Hello &amp;amp;lt;Ada&amp;amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output is escaped by default, as you'd expect. Real templates live under &lt;code&gt;resources/views&lt;/code&gt; and use the directives you'd guess: &lt;code&gt;@if&lt;/code&gt;, &lt;code&gt;@foreach&lt;/code&gt;, &lt;code&gt;@include&lt;/code&gt;, &lt;code&gt;@extends&lt;/code&gt; with &lt;code&gt;@section&lt;/code&gt; and &lt;code&gt;@yield&lt;/code&gt;, &lt;code&gt;@push&lt;/code&gt; and &lt;code&gt;@stack&lt;/code&gt;, fragments, and &lt;code&gt;&amp;lt;x-name&amp;gt;&lt;/code&gt; components with props and slots.&lt;/p&gt;

&lt;h2&gt;
  
  
  Some decisions I made
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Expressions are deliberately small.&lt;/strong&gt; No function calls and no filters inside a template. If a template needs a value, the handler computes it. It costs a bit of convenience, but templates stay easy to read and review.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Typed components.&lt;/strong&gt; You can back a component with a Rust struct, so props are checked by the compiler and not by luck.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;@dump&lt;/code&gt; is development-only.&lt;/strong&gt; It sits behind a Cargo feature, and a default release build contains no dump code. CI checks that on every push. The Laravel adapter also refuses to boot with &lt;code&gt;@dump&lt;/code&gt; on outside &lt;code&gt;local&lt;/code&gt; or &lt;code&gt;testing&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Errors point at your template.&lt;/strong&gt; Failures from the backend are mapped back to the original line and column.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Laravel Rust adapter
&lt;/h2&gt;

&lt;p&gt;If you use &lt;a href="https://laravel.com/rust" rel="noopener noreferrer"&gt;Laravel Rust&lt;/a&gt;, there's an optional &lt;code&gt;laravel&lt;/code&gt; feature with a &lt;code&gt;SwordServiceProvider&lt;/code&gt;. It registers the engine, exposes &lt;code&gt;@env&lt;/code&gt;, &lt;code&gt;@session&lt;/code&gt;, &lt;code&gt;@context&lt;/code&gt; and &lt;code&gt;@vite&lt;/code&gt;, and reads its settings from the usual config.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="k"&gt;[dependencies]&lt;/span&gt;
&lt;span class="na"&gt;rustysan-sword&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"0.1.1"&lt;/span&gt;
&lt;span class="c1"&gt;# rustysan-sword = { version = "0.1.1", features = ["laravel"] }
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;crates.io: &lt;a href="https://crates.io/crates/rustysan-sword" rel="noopener noreferrer"&gt;https://crates.io/crates/rustysan-sword&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GitHub: &lt;a href="https://github.com/rustysan/sword" rel="noopener noreferrer"&gt;https://github.com/rustysan/sword&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Docs: &lt;a href="https://docs.rs/rustysan-sword" rel="noopener noreferrer"&gt;https://docs.rs/rustysan-sword&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's an early release (0.1.1), and the expression rules are still settling, so only use trusted template authors for now. If something breaks or a directive you rely on is missing, open an issue. I'd like to hear about it.&lt;/p&gt;

</description>
      <category>rust</category>
      <category>webdev</category>
      <category>laravel</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
