Skip to content
This repository has been archived by the owner on Sep 14, 2019. It is now read-only.

Latest commit

 

History

History
38 lines (27 loc) · 791 Bytes

getting_started.md

File metadata and controls

38 lines (27 loc) · 791 Bytes

Getting started

First off, add maud to your Cargo.toml:

[dependencies]
# ...
maud = "*"

Now save the following to src/main.rs:

#![feature(proc_macro_hygiene)]

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'll (hopefully) get the following:

<p>Hi, Lyra!</p>

Congrats – you've written your first Maud program!