maud/docs/content/getting-started.md
Chris Wong b670d85595
Update documentation to account for stable support ()
* Remove `#![feature(proc_macro_hygiene)]` from documentation

Closes 

* Update comment about nightly vs stable
2020-10-08 11:02:19 +13:00

1.2 KiB
Raw Blame History

Getting started

Which version of Rust?

While Maud works well on both stable and nightly versions of Rust, the error messages are slightly better on nightly. For this reason, it is recommended to develop using nightly Rust but test and deploy using stable.

Add Maud to your project

Once Rust is set up, create a new project with Cargo:

cargo new --bin pony-greeter
cd pony-greeter

Add maud to your Cargo.toml:

[dependencies]
maud = "*"

Then save the following to src/main.rs:

extern crate maud;
use maud::html;

fn main() {
    let name = "Lyra";
    let markup = html! {
        p { "Hi, " (name) "!" }
    };
    println!("{}", markup.into_string());
}

html! takes a single argument: a template using Maud's custom syntax. This call expands to an expression of type Markup, which can then be converted to a String using .into_string().

Run this program with cargo run, and you should get the following:

<p>Hi, Lyra!</p>

Congrats you've written your first Maud program!