mirror of
https://github.com/askama-rs/askama.git
synced 2026-05-06 15:38:04 +00:00
Fix whitespace handling for include blocks (fixes #69)
This commit is contained in:
@@ -512,7 +512,7 @@ impl<'a> Generator<'a> {
|
||||
}
|
||||
|
||||
fn handle_include(&mut self, state: &'a State, ws: &WS, path: &str) {
|
||||
self.prepare_ws(ws);
|
||||
self.flush_ws(ws);
|
||||
let path = path::find_template_from_path(path, Some(&state.input.path));
|
||||
let src = path::get_template_source(&path);
|
||||
let nodes = parser::parse(&src);
|
||||
@@ -522,7 +522,7 @@ impl<'a> Generator<'a> {
|
||||
gen.buf
|
||||
};
|
||||
self.buf.push_str(&nested);
|
||||
self.flush_ws(ws);
|
||||
self.prepare_ws(ws);
|
||||
}
|
||||
|
||||
fn write_let_decl(&mut self, ws: &WS, var: &'a Target) {
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{% for s in strs -%}
|
||||
{% for s in strs %}
|
||||
{% include "included.html" %}
|
||||
{%- endfor %}
|
||||
|
||||
@@ -13,5 +13,5 @@ struct IncludeTemplate<'a> {
|
||||
fn test_include() {
|
||||
let strs = vec!["foo", "bar"];
|
||||
let s = IncludeTemplate { strs: &strs };
|
||||
assert_eq!(s.render().unwrap(), "INCLUDED: fooINCLUDED: bar")
|
||||
assert_eq!(s.render().unwrap(), "\n INCLUDED: foo\n INCLUDED: bar")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user