markup 0.1.3

A blazing fast, type-safe template engine for Rust.
Documentation
### Define

```rust
markup::define! {
    First {
      "First!"
    }
    Second {
      "Second!"
    }
}
```

```rust
println!("{}", First);
println!("{}", Second.to_string());
```

```html
First!
Second!
```

### Literal Strings and Expressions

+ Hello {
    "Hello,"
    " "
    "world!\n"
    {1 + 2}
    {format!("{}{}", 3, 4)}
    {if true { Some(5) } else { None }}
    {if false { Some(6) } else { None }}
}
- Hello {}

### Elements

#### Normal and Void

+ Hello {
    div
    br;
}
- Hello {}

#### id and class shorthands

+ Hello {
    button#go.button."button-blue"
    button#"go-back".{1 + 2}.{2 + 3}
}
- Hello {}

#### Attributes with and without values

+ Hello {
    div[a = 1, b = "2", c? = true, d? = false, "e-f" = 3, {"g".to_string() + "-h"} = 4, i = None::<i32>, j = Some(5)]
    br[k = 6];
}
- Hello {}

#### Children

+ Hello {
    div[a = 1] {
        "One"
        {0 + 1}
    }
    div {
        "Two"
        {1 + 1}
    }
}
- Hello {}

### Disable Automatic HTML Escaping

+ Hello {
    "<&\">"
    {markup::Raw("<span></span>")}
}
- Hello {}

### Arguments

+ Hello(foo: u32, bar: u32, string: String) {
    div {
        {foo + bar}
        {string}
    }
}
- Hello { foo: 1, bar: 2, string: String::from("hello") }

+ Hello<'a, T: std::fmt::Debug, U>(arg: T, arg2: U, str: &'a str) where U: std::fmt::Display {
    div {
        {format!("{:?}", arg)}
        {format!("{}", arg2)}
        {str}
    }
}
- Hello { arg: (1, 2), arg2: "arg2", str: "str" }

### Embed Other Templates

+ Add(a: u32, b: u32) {
    span { {a + b} }
}
Hello {
    {Add { a: 1, b: 2 }}
    {Add { a: 3, b: 4 }}
}
- Hello {}

### If

+ Classify(value: i32) {
    {value}
    " is "
    @if *value < 0 {
        "negative"
    } else if *value == 0 {
        "zero"
    } else {
        "positive"
    }
    ".\n"
}
Main {
    {Classify { value: -42 }}
    " "
    {Classify { value: 0 }}
    " "
    {Classify { value: 42 }}
}
- Main {}

### For

+ Main {
    @for i in 1..5 {
        {i} " * 2 = " {i * 2} ";\n"
    }
}
- Main {}