Skip to content

Commit

Permalink
chore: minor cleanup for chained else support in #629
Browse files Browse the repository at this point in the history
  • Loading branch information
sunng87 committed Jan 16, 2024
1 parent e30d8ab commit 137bce5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [Unreleased](https://github.com/sunng87/handlebars-rust/compare/5.0.0...Unreleased) - ReleaseDate

* [Added] Chained `else if` block support [#629]

## [5.0.0](https://github.com/sunng87/handlebars-rust/compare/4.3.4...5.0.0) - 2023-12-31

* [Added] public mutable access to local variables in `BlockContext` [#533]
Expand Down
15 changes: 15 additions & 0 deletions src/helpers/helper_if.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,21 @@ mod test {
);
}

#[test]
fn test_if_else_chain4() {
let handlebars = Registry::new();

assert_eq!(
"1".to_owned(),
handlebars
.render_template(
"{{#if a}}1{{else if b}}2{{else if c}}3{{else if d}}4{{/if}}",
&json!({"a":1})
)
.unwrap()
);
}

#[test]
fn test_if_include_zero() {
use std::f64;
Expand Down
4 changes: 0 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@
//! First of all, mustache blocks are not supported. I suggest you to use `#if` and `#each` for
//! the same functionality.
//!
//! There are some other minor features missing:
//!
//! * Chained else [#12](https://github.com/sunng87/handlebars-rust/issues/12)
//!
//! Feel free to file an issue on [github](https://github.com/sunng87/handlebars-rust/issues) if
//! you find missing features.
//!
Expand Down
12 changes: 0 additions & 12 deletions src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,18 +665,6 @@ impl Parameter {
}
}

impl Renderable for HelperTemplate {
fn render<'reg: 'rc, 'rc>(
&'rc self,
registry: &'reg Registry<'reg>,
ctx: &'rc Context,
rc: &mut RenderContext<'reg, 'rc>,
out: &mut dyn Output,
) -> Result<(), RenderError> {
render_helper(self, registry, ctx, rc, out)
}
}

impl Renderable for Template {
fn render<'reg: 'rc, 'rc>(
&'rc self,
Expand Down

0 comments on commit 137bce5

Please sign in to comment.