Skip to content
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

Bug: Partials don't inherit indentation #78

Open
a-lafrance opened this issue Jul 1, 2022 · 0 comments
Open

Bug: Partials don't inherit indentation #78

a-lafrance opened this issue Jul 1, 2022 · 0 comments

Comments

@a-lafrance
Copy link

When using a partial with indentation, only the first line is indented; the rest of the partial is rendered unindented. However, partials must inherit indentation as described in the spec, so I think this is a bug?

Here's a minimal example to reproduce the issue:

#[macro_use]
extern crate serde_derive;

use maplit::hashmap;
use std::io;

#[derive(Serialize)]
struct Person {
    name: String,
}

fn main() {
    let template = mustache::compile_path("greet_all.mustache").unwrap();
    let people = hashmap! { "people" => vec![
        Person { name: "Alice".to_string() },
        Person { name: "Bob".to_string() },
    ]};

    template.render(&mut io::stdout(), &people).unwrap();
    println!();
}

Given templates:

{{! greet.mustache }}
hello {{{name}}}
nice to see you today
{{! greet_all.mustache }}
{{#people}}
    {{> greet}}
{{/people}}

It should print:

    hello Alice
    nice to see you today

    hello Bob
    nice to see you today

But prints:

    hello Alice
nice to see you today

    hello Bob
nice to see you today
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant