From aa98f61fa78b2a81e47419feae188308d30bacf6 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Fri, 3 Mar 2017 16:44:54 +0100 Subject: Discard trailing newlines from templates by default This matches Jinja's behavior, and seems sensible. --- testing/tests/filters.rs | 4 ++-- testing/tests/inheritance.rs | 4 ++-- testing/tests/operators.rs | 2 +- testing/tests/simple.rs | 18 +++++++++--------- 4 files changed, 14 insertions(+), 14 deletions(-) (limited to 'testing/tests') diff --git a/testing/tests/filters.rs b/testing/tests/filters.rs index 73b660a..5882bae 100644 --- a/testing/tests/filters.rs +++ b/testing/tests/filters.rs @@ -16,7 +16,7 @@ fn filter_escape() { strvar: "my is unsafe & should be escaped".to_string(), }; assert_eq!(s.render(), - "my <html> is unsafe & should be escaped\n"); + "my <html> is unsafe & should be escaped"); } @@ -29,5 +29,5 @@ struct FormatTemplate<'a> { #[test] fn filter_format() { let t = FormatTemplate { var: "formatted" }; - assert_eq!(t.render(), "\"formatted\"\n"); + assert_eq!(t.render(), "\"formatted\""); } diff --git a/testing/tests/inheritance.rs b/testing/tests/inheritance.rs index 2fd06ba..b3add1c 100644 --- a/testing/tests/inheritance.rs +++ b/testing/tests/inheritance.rs @@ -19,11 +19,11 @@ struct ChildTemplate<'a> { #[test] fn test_use_base_directly() { let t = BaseTemplate { title: "Foo" }; - assert_eq!(t.render(), "Foo\n\nCopyright 2017\n"); + assert_eq!(t.render(), "Foo\n\nCopyright 2017"); } #[test] fn test_simple_extends() { let t = ChildTemplate { _parent: BaseTemplate { title: "Bar" } }; - assert_eq!(t.render(), "Bar\nContent goes here\nCopyright 2017\n"); + assert_eq!(t.render(), "Bar\nContent goes here\nCopyright 2017"); } diff --git a/testing/tests/operators.rs b/testing/tests/operators.rs index 73745f0..70d26b1 100644 --- a/testing/tests/operators.rs +++ b/testing/tests/operators.rs @@ -15,7 +15,7 @@ struct CompareTemplate { #[test] fn test_compare() { let t = CompareTemplate { a: 1, b: 1, c: 2 }; - assert_eq!(t.render(), "tf\ntf\ntf\ntf\ntf\ntf\n"); + assert_eq!(t.render(), "tf\ntf\ntf\ntf\ntf\ntf"); } diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs index 454c1e2..2f69c84 100644 --- a/testing/tests/simple.rs +++ b/testing/tests/simple.rs @@ -22,7 +22,7 @@ fn test_variables() { assert_eq!(s.render(), "hello world, foo\n\ with number: 42\n\ Iñtërnâtiônàlizætiøn is important\n\ - in vars too: Iñtërnâtiônàlizætiøn\n"); + in vars too: Iñtërnâtiônàlizætiøn"); } @@ -35,7 +35,7 @@ struct IfTemplate { #[test] fn test_if() { let s = IfTemplate { cond: true }; - assert_eq!(s.render(), "true\n"); + assert_eq!(s.render(), "true"); } @@ -48,7 +48,7 @@ struct ElseTemplate { #[test] fn test_else() { let s = ElseTemplate { cond: false }; - assert_eq!(s.render(), "false\n"); + assert_eq!(s.render(), "false"); } @@ -62,7 +62,7 @@ struct ElseIfTemplate { #[test] fn test_else_if() { let s = ElseIfTemplate { cond: false, check: true }; - assert_eq!(s.render(), "checked\n"); + assert_eq!(s.render(), "checked"); } @@ -77,7 +77,7 @@ fn test_for() { let s = ForTemplate { strings: vec!["A", "alfa", "1"], }; - assert_eq!(s.render(), "0. A\n1. alfa\n2. 1\n\n"); + assert_eq!(s.render(), "0. A\n1. alfa\n2. 1\n"); } @@ -88,7 +88,7 @@ struct LiteralsTemplate {} #[test] fn test_literals() { let s = LiteralsTemplate {}; - assert_eq!(s.render(), "a\n"); + assert_eq!(s.render(), "a"); } @@ -105,7 +105,7 @@ struct AttrTemplate { #[test] fn test_attr() { let t = AttrTemplate { inner: Holder { a: 5 } }; - assert_eq!(t.render(), "5\n"); + assert_eq!(t.render(), "5"); } @@ -118,7 +118,7 @@ struct OptionTemplate<'a> { #[test] fn test_option() { let some = OptionTemplate { var: Some("foo") }; - assert_eq!(some.render(), "some: foo\n"); + assert_eq!(some.render(), "some: foo"); let none = OptionTemplate { var: None }; - assert_eq!(none.render(), "none\n"); + assert_eq!(none.render(), "none"); } -- cgit