New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document html composability clearly (aka partials) #6

merged 3 commits into from Aug 23, 2018
Jump to file or symbol
Failed to load files and symbols.
+60 −0
Diff settings


Just for now

Copy path View file
@@ -4,6 +4,7 @@
* [Getting started](
* [Basic syntax](
* [Dynamic content](
* [Partials](
* [Control structures](
* [The `Render` trait](
* [Web framework integration](
Copy path View file
@@ -0,0 +1,59 @@
# Partials
Maud does not have a built-in concept of partials or sub-templates. Instead, you can compose your markup with any function that returns `Markup`.
The following example uses a `header` and `footer` function that are used in the `page` function to return a final result.
extern crate maud;
use self::maud::{DOCTYPE, html, Markup};
/// A basic header with a dynamic `page_title`.
fn header(page_title: &str) -> Markup {
html! {
html {
meta charset="utf-8";
title { (page_title) }
/// A static footer.
fn footer() -> Markup {
html! {
footer {
span {
a href="rss.atom" { "RSS Feed" }
/// The final Markup, including `header` and `footer`.
/// Additionally takes a `greeting_box` that's `Markup`, not `&str`.
pub fn page(title: &str, greeting_box: Markup) -> Markup {
html! {
// Add the header markup to the page
body {
h1 { "Hello World" }
// Add the footer markup to the page
Using the `page` function will return the markup for the whole page and looks like this:
fn main() {
page("Hello!", html! {
div { "Greetings, Maud." }
ProTip! Use n and p to navigate between commits in a pull request.