diff --git a/maud/Cargo.toml b/maud/Cargo.toml index 5d72b56..7dcf71c 100644 --- a/maud/Cargo.toml +++ b/maud/Cargo.toml @@ -14,3 +14,4 @@ Compile-time HTML templates. [dependencies] iron = { version = "0.4.0", optional = true } +rocket = { version = "0.1.2", optional = true } diff --git a/maud/src/lib.rs b/maud/src/lib.rs index 25fc594..3dfde63 100644 --- a/maud/src/lib.rs +++ b/maud/src/lib.rs @@ -8,6 +8,7 @@ //! [book]: https://maud.lambda.xyz/ #[cfg(feature = "iron")] extern crate iron; +#[cfg(feature = "rocket")] extern crate rocket; use std::fmt::{self, Write}; @@ -207,3 +208,16 @@ mod iron_support { } } } + +#[cfg(feature = "rocket")] +mod rocket_support { + use rocket::http::Status; + use rocket::response::{Responder, Response}; + use PreEscaped; + + impl Responder<'static> for PreEscaped<String> { + fn respond(self) -> Result<Response<'static>, Status> { + self.into_string().respond() + } + } +}