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

Panic on rendering boolean #60

Open
justinpombrio opened this issue Jul 20, 2018 · 2 comments
Open

Panic on rendering boolean #60

justinpombrio opened this issue Jul 20, 2018 · 2 comments

Comments

@justinpombrio
Copy link

This program:

extern crate mustache;

use std::io;
use mustache::MapBuilder;

fn main() {
    let template = mustache::compile_str("{{ok}}").unwrap();
    let data = MapBuilder::new()
        .insert_bool("ok", true)
        .build();
    template.render_data(&mut io::stdout(), &data).unwrap();
    println!();
}

fails with the following error:

thread 'main' panicked at 'bug: render_utag: unexpected value Bool(true).
Please report this issue on GitHub if you find an input that triggers this case.',
/home/justin/.cargo/registry/src/github.com-1ecc6299db9ec823/mustache-0.9.0/src/template.rs:224:25

Instead, I expect it to produce:

true

My thoughts:

  • It would be nice to be able to use booleans in a template like {{ok}} and get 'true' or 'false'.
  • Even if booleans can only be used as {{#ok}}...{{/ok}}, this is a poor error message.
  • This error occurs in render_utag, but why should this be unescaped?
@Ryman
Copy link
Member

Ryman commented Aug 12, 2018

Hi @justinpombrio, Thanks for the bug report!

You're right indeed this should be supported, I have submitted #61 which should hopefully fix your issue.

This error occurs in render_utag, but why should this be unescaped?

The rendering all happens through raw output and then converted to escaped variants after, see here if you are interested or want to improve it :)

@justinpombrio
Copy link
Author

Thanks even more for the bug fix!

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

Successfully merging a pull request may close this issue.

2 participants