-
-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Whitespace issue with if conditions #377
Comments
It sure sounds like a bug! Let me look at some code. |
So the code generation for if statements is here: https://github.com/djc/askama/blob/main/askama_shared/src/generator.rs#L502 I don't immediately see anything obviously wrong. Maybe you can contribute a test case and/or use the debugging facility (add |
@djc I've added the test. Using fn render_into(&self, writer: &mut dyn ::std::fmt::Write) -> ::askama::Result<()> {
include_bytes !
("/home/ajeetdsouza/ws/askama/testing/templates/cond-whitespace.txt") ;
if self.show_preamble {
writer.write_str("preamble")?;
}
writer.write_str("\n\nintroduction\n\nconclusion")?;
Ok(())
} |
Askama seems to be including whitespace from inside an if condition even when the condition is not fulfilled. Here is my template file:
What I expected is:
When
some_condition
istrue
:When
some_condition
isfalse
:What I got is:
When
some_condition
istrue
: same as expected outputWhen
some_condition
isfalse
(notice the blank lines beforeFILE START
):Is this a bug? If not, is there a way to get the behaviour I described?
The text was updated successfully, but these errors were encountered: