aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2019-03-18 10:21:34 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2019-03-18 10:21:34 +0100
commit703ab6e3c7b3a885a5745949750ca54b68dd4569 (patch)
treee9394c11014e07693c676fb032cc0d4e6cbd719f
parentd9ee26bfa2685fba3ead8e4e64fd6efd92ab228d (diff)
downloadaskama-703ab6e3c7b3a885a5745949750ca54b68dd4569.tar.gz
askama-703ab6e3c7b3a885a5745949750ca54b68dd4569.tar.bz2
askama-703ab6e3c7b3a885a5745949750ca54b68dd4569.zip
Remove second example for templates in templates
-rw-r--r--askama/src/lib.rs3
-rw-r--r--testing/tests/render_with_enums.rs93
2 files changed, 0 insertions, 96 deletions
diff --git a/askama/src/lib.rs b/askama/src/lib.rs
index d1c18c5..bd5078f 100644
--- a/askama/src/lib.rs
+++ b/askama/src/lib.rs
@@ -398,9 +398,6 @@
//! [render in place](https://github.com/djc/askama/blob/master/testing/tests/render_in_place.rs)
//! using a vector of templates in a for block.
//!
-//! See the example [using enums](https://github.com/djc/askama/blob/master/testing/tests/render_with_enums.rs)
-//! for another use case. You can use different template parts depending on the context.
-//!
//! ## Comments
//!
//! Askama supports block comments delimited by `{#` and `#}`.
diff --git a/testing/tests/render_with_enums.rs b/testing/tests/render_with_enums.rs
deleted file mode 100644
index cb83c39..0000000
--- a/testing/tests/render_with_enums.rs
+++ /dev/null
@@ -1,93 +0,0 @@
-use askama::Template;
-
-enum SectionOneType<'a> {
- Empty(TEmpty),
- Simple(TSecOneSimple<'a>),
- Full(TSecOneFull<'a>),
-}
-impl<'a> SectionOneType<'a> {
- pub fn render(&self) -> askama::Result<String> {
- match self {
- SectionOneType::Empty(v) => v.render(),
- SectionOneType::Simple(v) => v.render(),
- SectionOneType::Full(v) => v.render(),
- }
- }
-}
-enum SectionTwoFormat<'a> {
- Html(TSecTwoHtml<'a>),
- Text(TSecTwoText<'a>),
-}
-impl<'a> SectionTwoFormat<'a> {
- pub fn render(&self) -> askama::Result<String> {
- match self {
- SectionTwoFormat::Html(v) => v.render(),
- SectionTwoFormat::Text(v) => v.render(),
- }
- }
-}
-#[derive(Template)]
-#[template(path = "render_in_place.html")]
-struct RenderInPlace<'a> {
- s1: SectionOneType<'a>,
- s2: SectionTwoFormat<'a>,
- s3: &'a Vec<SectionOneType<'a>>,
-}
-
-#[derive(Template)]
-#[template(source = "", ext = "txt")]
-struct TEmpty {}
-#[derive(Template)]
-#[template(source = "{{ a }}", ext = "txt")]
-struct TSecOneSimple<'a> {
- a: &'a str,
-}
-#[derive(Template)]
-#[template(source = "{{ a }}, {{ b }}", ext = "txt")]
-struct TSecOneFull<'a> {
- a: &'a str,
- b: &'a str,
-}
-
-#[derive(Template)]
-#[template(source = "<span>{{ c }}</span><p>{{ d }}</p>", ext = "html")]
-struct TSecTwoHtml<'a> {
- c: &'a str,
- d: &'a str,
-}
-#[derive(Template)]
-#[template(source = "{{ c }}, {{ d }}", ext = "txt")]
-struct TSecTwoText<'a> {
- c: &'a str,
- d: &'a str,
-}
-
-#[test]
-fn test_render_with_enums() {
- let t = RenderInPlace {
- s1: SectionOneType::Empty(TEmpty {}),
- s2: SectionTwoFormat::Html(TSecTwoHtml { c: "C", d: "D" }),
- s3: &vec![
- SectionOneType::Empty(TEmpty {}),
- SectionOneType::Simple(TSecOneSimple { a: "A" }),
- SectionOneType::Full(TSecOneFull { a: "A", b: "B" }),
- ],
- };
- assert_eq!(
- t.render().unwrap(),
- "Section 1: \nSection 2: <span>C</span><p>D</p>\nSection 3 for:\n* \n* A\n* A, B\n"
- );
- let t = RenderInPlace {
- s1: SectionOneType::Empty(TEmpty {}),
- s2: SectionTwoFormat::Text(TSecTwoText { c: "C", d: "D" }),
- s3: &vec![
- SectionOneType::Empty(TEmpty {}),
- SectionOneType::Simple(TSecOneSimple { a: "A" }),
- SectionOneType::Full(TSecOneFull { a: "A", b: "B" }),
- ],
- };
- assert_eq!(
- t.render().unwrap(),
- "Section 1: \nSection 2: C, D\nSection 3 for:\n* \n* A\n* A, B\n"
- );
-}