TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Maud: a fast, safe template engine for Rust

93 pointsby aethertapalmost 10 years ago

7 comments

kibwenalmost 10 years ago
It&#x27;s interesting to see how Maud&#x27;s approach uses syntax extensions, in contrast to the less-powerful (but more stable) macro-based approach that Horrorshow uses: <a href="https:&#x2F;&#x2F;users.rust-lang.org&#x2F;t&#x2F;horrorshow-a-no-longer-poc-html-template-library&#x2F;1603" rel="nofollow">https:&#x2F;&#x2F;users.rust-lang.org&#x2F;t&#x2F;horrorshow-a-no-longer-poc-htm...</a><p>I also wonder if Maud could benefit from the Syntex library (<a href="https:&#x2F;&#x2F;github.com&#x2F;erickt&#x2F;rust-syntex" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;erickt&#x2F;rust-syntex</a>) which uses a fork of Rust&#x27;s (currently unstable) parsing library to enable syntax extensions to work on the stable Rust release via code generation.
JoshTriplettalmost 10 years ago
Very glad to see this. I&#x27;ve used type-safe templates in Haskell, and I&#x27;ve been hoping to see something similar in Rust. It looks like Maud has good defaults as well, such as escaping HTML by default.<p>I wonder if it would make sense to have splicing of previously created Maud values <i>not</i> escape them. That seems like the most common case where you&#x27;d end up using $$ otherwise: piecemeal generation of HTML fragments. Since Maud has a special type to represent the result of a template, it could recognize that type in a splice.<p>Also, the need to handle control structures inline (such as $if and $for) seems like it could be replaced with a mechanism to splice in arbitrary Rust code of the appropriate type. Because otherwise, Maud would need to handle things like $match.<p>Props for the name and documentation as well.
评论 #9628564 未加载
Animatsalmost 10 years ago
Oh, an <i>HTML</i> template engine, like PHP. Not a Rust code generator, like &quot;go generate&quot;. The HN article title should specify that.
allan_salmost 10 years ago
I started (and put aside) quite some times ago something with the similar approach, i.e using syntax extension but to actually write &quot;real&quot; html, in a template-language flavor<p><a href="https:&#x2F;&#x2F;github.com&#x2F;allan-simon&#x2F;rust-http-template" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;allan-simon&#x2F;rust-http-template</a><p>I first wanted it to be used with Iron, but unfortunately I lost motivation when I saw that syntax extension will not be part of 1.0 . if people are interested I can revive it.
riquitoalmost 10 years ago
In &quot;basic syntax&quot; I suggest you to move the doc about &quot;Splices&quot; after &quot;Elements&quot;, since the latter it&#x27;s used in the former example (or even later since it&#x27;s more complex than other things).
ufoalmost 10 years ago
I wonder if there is a way to write a macro library that can use regular `if` and `for` instead of `$if` and `$for`.
评论 #9626770 未加载
评论 #9629123 未加载
tmalyalmost 10 years ago
sorry to high jack the topic, whats the big deal with Rust? I have heard it has memory safety, but are the language syntax and standard library stable?
评论 #9630280 未加载
评论 #9629926 未加载