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

Document html composability clearly (aka partials) #6

Merged
merged 3 commits into from Aug 23, 2018

Conversation

phansch
Copy link
Contributor

@phansch phansch commented Aug 14, 2018

When I was evaluating maud, I ran into the same issue as @max-frai regarding partials/sub templates. This documents that it's super easy to compose the templates using plain Rust functions.

Closes lambda-fairy/maud#133

Copy link
Owner

@lambda-fairy lambda-fairy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I like the approach you're taking here.

partials.md Outdated

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 uses a `header` and `footer` function that are used in the `page` function to return a final result.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following example?

partials.md Outdated
}

/// The final Markup, including `header` and `footer`.
pub fn page(title: &str) -> Markup {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth demonstrating that functions can accept Markup values as well as return them.

See the first few lines of https://github.com/lfairy/karkinos/blob/master/src/views.rs

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense 👍

partials.md Outdated
@@ -0,0 +1,50 @@
# 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`.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sub-templates has a hyphen I think

@lambda-fairy lambda-fairy merged commit 0dba5a1 into lambda-fairy:master Aug 23, 2018
@lambda-fairy
Copy link
Owner

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants