sunng87 / handlebars-rust

Rust templating with Handlebars

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Each loop not aligned with inline

htakao opened this issue · comments

commented

When looping through items in each with inline, that not aligned.

use handlebars::Handlebars;
use serde_json::json;

fn main() {
    let reg = Handlebars::new();

    let tpl = r#"
<!-- without inline -->
<ul>
  {{#each a}}
    <li>{{this}}</li>
  {{/each}}
</ul>

<!-- with inline -->
{{#*inline "li"}}
{{#each a}}
  <li>{{this}}</li>
{{/each}}
{{/inline}}
<ul>
  {{> li}}
</ul>
"#;

    println!(
        "{}",
        reg.render_template(tpl, &json!({"a": [0, 1]})).unwrap()
    );
}

Output

<!-- without inline -->
<ul>
    <li>0</li>
    <li>1</li>
</ul>

<!-- with inline -->
<ul>
    <li>0</li>
  <li>1</li>
</ul>

It works fine in handlebars.js.
Handlebars.js Playground

This should be duplicated as reported in #573. I'm still seeking for an elegant solution for this. Attempted in #574

commented

Sorry for taking up your time. Thank you.