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

support for else if #586

Closed
lovasoa opened this issue Jun 10, 2023 · 8 comments
Closed

support for else if #586

lovasoa opened this issue Jun 10, 2023 · 8 comments

Comments

@lovasoa
Copy link
Contributor

lovasoa commented Jun 10, 2023

Hello !
Is support for else if planned in this library ?
That would be very practical in sqlpage

Thank you !
Ophir

@murilobr
Copy link

@lovasoa
Copy link
Contributor Author

lovasoa commented Aug 15, 2023

What do you mean ?

@hyperupcall
Copy link

@lovasoa That page contains an example of else if in handlebars. Since this library is compatible with the Handlebars syntax, you should be able to use it and things should Just Work.

@lovasoa
Copy link
Contributor Author

lovasoa commented Sep 14, 2023

No, it's not supported, that's why I opened this PR.

use handlebars::Handlebars;
use serde_json::json;
use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
    let mut reg = Handlebars::new();
    println!(
        "{}",
        reg.render_template(
          "
          {{#if isActive}}
              active
          {{else if isInactive}}
             inactive
          {{else}}
             unknown
          {{/if}}
          ", &json!({"isInactive": true}))?
    );

    Ok(())
}
$ cargo run
             unknown

@hyperupcall
Copy link

After a quick search, it seems that else-ifs are not present in the current testing suite.

@jqiris
Copy link

jqiris commented Jan 11, 2024

encounter the same problem,how to solve?

@42triangles
Copy link

There's an open issue for this: #12

As is, it is sadly not supported.

@sunng87
Copy link
Owner

sunng87 commented Jan 16, 2024

Fixed in #629

@sunng87 sunng87 closed this as completed Jan 16, 2024
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

6 participants