From b9cb5b82e6c87bf0f6037d097476d69f5241bf3a Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Sun, 6 Aug 2017 14:51:56 +0200 Subject: Merge handling of trailing newline into get_template_source() --- askama_derive/src/path.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'askama_derive/src/path.rs') diff --git a/askama_derive/src/path.rs b/askama_derive/src/path.rs index e48f7d7..28b1b17 100644 --- a/askama_derive/src/path.rs +++ b/askama_derive/src/path.rs @@ -46,6 +46,9 @@ pub fn get_template_source(tpl_file: &str) -> String { }; let mut s = String::new(); f.read_to_string(&mut s).unwrap(); + if s.ends_with('\n') { + let _ = s.pop(); + } s } @@ -56,7 +59,7 @@ mod tests { #[test] fn get_source() { - assert_eq!(get_template_source("sub/b.html"), "bar\n"); + assert_eq!(get_template_source("sub/b.html"), "bar"); } #[test] -- cgit