aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--askama/src/lib.rs5
-rw-r--r--testing/tests/filters.rs4
-rw-r--r--testing/tests/inheritance.rs4
-rw-r--r--testing/tests/operators.rs2
-rw-r--r--testing/tests/simple.rs18
5 files changed, 18 insertions, 15 deletions
diff --git a/askama/src/lib.rs b/askama/src/lib.rs
index 73313b7..dae237d 100644
--- a/askama/src/lib.rs
+++ b/askama/src/lib.rs
@@ -70,7 +70,10 @@ fn get_template_meta(ast: &syn::DeriveInput) -> TemplateMeta {
/// value as passed to the `template()` attribute.
pub fn build_template(ast: &syn::DeriveInput) -> String {
let meta = get_template_meta(ast);
- let src = path::get_template_source(&meta.path);
+ let mut src = path::get_template_source(&meta.path);
+ if src.ends_with('\n') {
+ let _ = src.pop();
+ }
let nodes = parser::parse(&src);
if meta.print == "ast" || meta.print == "all" {
println!("{:?}", nodes);
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 <html> is unsafe & should be escaped".to_string(),
};
assert_eq!(s.render(),
- "my &lt;html&gt; is unsafe &amp; should be escaped\n");
+ "my &lt;html&gt; is unsafe &amp; 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");
}