Remove maud_extras
crate (#168)
I don't think the examples in this crate are very useful, or demonstrate how to best use the library.
This commit is contained in:
parent
be10b9837e
commit
5b027d08ae
6 changed files with 2 additions and 224 deletions
|
@ -18,7 +18,7 @@ script:
|
|||
- |
|
||||
if $RUN_CLIPPY; then
|
||||
CLIPPY_STATUS=0
|
||||
for package in maud_htmlescape maud_macros maud maud_extras; do
|
||||
for package in maud_htmlescape maud_macros maud; do
|
||||
(cd $package && cargo clippy -- -D warnings) || CLIPPY_STATUS=$?
|
||||
done
|
||||
(exit $CLIPPY_STATUS)
|
||||
|
|
|
@ -3,7 +3,6 @@ members = [
|
|||
"maud_htmlescape",
|
||||
"maud_macros",
|
||||
"maud",
|
||||
"maud_extras",
|
||||
]
|
||||
exclude = [
|
||||
"benchmarks",
|
||||
|
|
|
@ -4,7 +4,7 @@ By default, a `(splice)` is rendered using the [`std::fmt::Display`][Display] tr
|
|||
|
||||
To change this behavior, implement the [`Render`][Render] trait for your type. Then, when a value of this type is used in a template, Maud will call your custom code instead.
|
||||
|
||||
Below are some examples of using `Render`. Feel free to use these snippets in your own project! For more examples, take a look at the [`maud_extras`][maud_extras] crate.
|
||||
Below are some examples of using `Render`. Feel free to use these snippets in your own project!
|
||||
|
||||
## Example: a shorthand for including CSS stylesheets
|
||||
|
||||
|
@ -75,7 +75,6 @@ impl<T: AsRef<str>> Render for Markdown<T> {
|
|||
}
|
||||
```
|
||||
|
||||
[maud_extras]: https://github.com/lfairy/maud/tree/master/maud_extras
|
||||
[Debug]: https://doc.rust-lang.org/std/fmt/trait.Debug.html
|
||||
[Display]: https://doc.rust-lang.org/std/fmt/trait.Display.html
|
||||
[Render]: https://docs.rs/maud/*/maud/trait.Render.html
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
[package]
|
||||
|
||||
name = "maud_extras"
|
||||
version = "0.0.0"
|
||||
authors = ["Chris Wong <lambda.fairy@gmail.com>"]
|
||||
|
||||
license = "CC0-1.0"
|
||||
repository = "https://github.com/lfairy/maud"
|
||||
description = "Extra bits and pieces for use in Maud templates."
|
||||
|
||||
[dependencies]
|
||||
maud = { path = "../maud", features = ["iron"] }
|
||||
|
||||
[lib]
|
||||
path = "lib.rs"
|
|
@ -1,12 +0,0 @@
|
|||
# maud\_extras
|
||||
|
||||
This crate contains various bits and pieces that can be used in Maud templates.
|
||||
|
||||
To use an item from this crate, simply copy-and-paste the code into your project. Depending on `maud_extras` directly is discouraged, since (a) it often receives breaking changes, and (b) it's unlikely that you'll need everything.
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome! Please note that all code in this repository is placed in the public domain ([CC0]).
|
||||
|
||||
[CC0]: https://creativecommons.org/publicdomain/zero/1.0/
|
|
@ -1,193 +0,0 @@
|
|||
#![feature(proc_macro_hygiene)]
|
||||
|
||||
extern crate maud;
|
||||
|
||||
use maud::{Markup, Render, html};
|
||||
|
||||
/// Links to an external stylesheet.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// # #![feature(proc_macro_hygiene)]
|
||||
/// # extern crate maud;
|
||||
/// # extern crate maud_extras;
|
||||
/// # use maud::html;
|
||||
/// # use maud_extras::*;
|
||||
/// # fn main() {
|
||||
/// let markup = html! { (Css("styles.css")) };
|
||||
/// assert_eq!(markup.into_string(),
|
||||
/// r#"<link rel="stylesheet" href="styles.css">"#);
|
||||
/// # }
|
||||
/// ```
|
||||
pub struct Css<T: AsRef<str>>(pub T);
|
||||
|
||||
impl<T: AsRef<str>> Render for Css<T> {
|
||||
fn render(&self) -> Markup {
|
||||
html! {
|
||||
link rel="stylesheet" href=(self.0.as_ref()) /
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Links to an external script.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// # #![feature(proc_macro_hygiene)]
|
||||
/// #
|
||||
/// # extern crate maud;
|
||||
/// # extern crate maud_extras;
|
||||
/// # use maud::html;
|
||||
/// # use maud_extras::*;
|
||||
/// # fn main() {
|
||||
/// let markup = html! { (Js("app.js")) };
|
||||
/// assert_eq!(markup.into_string(),
|
||||
/// r#"<script src="app.js"></script>"#);
|
||||
/// # }
|
||||
/// ```
|
||||
pub struct Js<T: AsRef<str>>(pub T);
|
||||
|
||||
impl<T: AsRef<str>> Render for Js<T> {
|
||||
fn render(&self) -> Markup {
|
||||
html! {
|
||||
script src=(self.0.as_ref()) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate a `<meta>` element.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// # #![feature(proc_macro_hygiene)]
|
||||
/// # extern crate maud;
|
||||
/// # extern crate maud_extras;
|
||||
/// # use maud::html;
|
||||
/// # use maud_extras::*;
|
||||
/// # fn main() {
|
||||
/// let markup = html! { (Meta("description", "test description")) };
|
||||
/// assert_eq!(markup.into_string(),
|
||||
/// r#"<meta name="description" content="test description">"#);
|
||||
/// # }
|
||||
/// ```
|
||||
pub struct Meta<T: AsRef<str>, U: AsRef<str>>(pub T, pub U);
|
||||
|
||||
impl<T: AsRef<str>, U: AsRef<str>> Render for Meta<T, U> {
|
||||
fn render(&self) -> Markup {
|
||||
html! {
|
||||
meta name=(self.0.as_ref()) content=(self.1.as_ref()) /
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate a `<title>` element.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// # #![feature(proc_macro_hygiene)]
|
||||
/// # extern crate maud;
|
||||
/// # extern crate maud_extras;
|
||||
/// # use maud::html;
|
||||
/// # use maud_extras::*;
|
||||
/// # fn main() {
|
||||
/// let markup = html! { (Title("Maud")) };
|
||||
/// assert_eq!(markup.into_string(),
|
||||
/// r#"<title>Maud</title>"#);
|
||||
/// # }
|
||||
/// ```
|
||||
pub struct Title<T: AsRef<str>>(pub T);
|
||||
|
||||
impl<T: AsRef<str>> Render for Title<T> {
|
||||
fn render(&self) -> Markup {
|
||||
html! {
|
||||
title { (self.0.as_ref()) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate a `<meta charset="...">` element.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// # #![feature(proc_macro_hygiene)]
|
||||
/// # extern crate maud;
|
||||
/// # extern crate maud_extras;
|
||||
/// # use maud::html;
|
||||
/// # use maud_extras::*;
|
||||
/// # fn main() {
|
||||
/// let markup = html! { (Charset("utf-8")) };
|
||||
/// assert_eq!(markup.into_string(),
|
||||
/// r#"<meta charset="utf-8">"#);
|
||||
/// # }
|
||||
/// ```
|
||||
pub struct Charset<T: AsRef<str>>(pub T);
|
||||
|
||||
impl<T: AsRef<str>> Render for Charset<T> {
|
||||
fn render(&self) -> Markup {
|
||||
html! {
|
||||
meta charset=(self.0.as_ref()) /
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate a `<meta property>` element.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// # #![feature(proc_macro_hygiene)]
|
||||
/// # extern crate maud;
|
||||
/// # extern crate maud_extras;
|
||||
/// # use maud::html;
|
||||
/// # use maud_extras::*;
|
||||
/// # fn main() {
|
||||
/// let markup = html! { (MetaProperty("og:description", "test description")) };
|
||||
/// assert_eq!(markup.into_string(),
|
||||
/// r#"<meta property="og:description" content="test description">"#);
|
||||
/// # }
|
||||
/// ```
|
||||
pub struct MetaProperty<T: AsRef<str>, U: AsRef<str>>(pub T, pub U);
|
||||
|
||||
impl<T: AsRef<str>, U: AsRef<str>> Render for MetaProperty<T, U> {
|
||||
fn render(&self) -> Markup {
|
||||
html! {
|
||||
meta property=(self.0.as_ref()) content=(self.1.as_ref()) /
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate a `<meta robots>` element.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// # #![feature(proc_macro_hygiene)]
|
||||
/// # extern crate maud;
|
||||
/// # extern crate maud_extras;
|
||||
/// # use maud::html;
|
||||
/// # use maud_extras::*;
|
||||
/// # fn main() {
|
||||
/// let markup = html! { (MetaRobots { index: true, follow: false }) };
|
||||
/// assert_eq!(markup.into_string(),
|
||||
/// r#"<meta name="robots" content="index,nofollow">"#);
|
||||
/// # }
|
||||
/// ```
|
||||
pub struct MetaRobots {
|
||||
pub index: bool,
|
||||
pub follow: bool,
|
||||
}
|
||||
|
||||
impl Render for MetaRobots {
|
||||
fn render(&self) -> Markup {
|
||||
let index = if self.index { "index" } else { "noindex" };
|
||||
let follow = if self.follow { "follow" } else { "nofollow" };
|
||||
html! {
|
||||
meta name="robots" content={ (index) "," (follow) } /
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue