Skip to content

Bug: Partials don't inherit indentation #78

@a-lafrance

Description

@a-lafrance

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions