Skip to content

Commit 137bce5

Browse files
committed
chore: minor cleanup for chained else support in #629
1 parent e30d8ab commit 137bce5

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## [Unreleased](https://github.com/sunng87/handlebars-rust/compare/5.0.0...Unreleased) - ReleaseDate
4+
5+
* [Added] Chained `else if` block support [#629]
6+
37
## [5.0.0](https://github.com/sunng87/handlebars-rust/compare/4.3.4...5.0.0) - 2023-12-31
48

59
* [Added] public mutable access to local variables in `BlockContext` [#533]

src/helpers/helper_if.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,21 @@ mod test {
138138
);
139139
}
140140

141+
#[test]
142+
fn test_if_else_chain4() {
143+
let handlebars = Registry::new();
144+
145+
assert_eq!(
146+
"1".to_owned(),
147+
handlebars
148+
.render_template(
149+
"{{#if a}}1{{else if b}}2{{else if c}}3{{else if d}}4{{/if}}",
150+
&json!({"a":1})
151+
)
152+
.unwrap()
153+
);
154+
}
155+
141156
#[test]
142157
fn test_if_include_zero() {
143158
use std::f64;

src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,6 @@
108108
//! First of all, mustache blocks are not supported. I suggest you to use `#if` and `#each` for
109109
//! the same functionality.
110110
//!
111-
//! There are some other minor features missing:
112-
//!
113-
//! * Chained else [#12](https://github.com/sunng87/handlebars-rust/issues/12)
114-
//!
115111
//! Feel free to file an issue on [github](https://github.com/sunng87/handlebars-rust/issues) if
116112
//! you find missing features.
117113
//!

src/render.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -665,18 +665,6 @@ impl Parameter {
665665
}
666666
}
667667

668-
impl Renderable for HelperTemplate {
669-
fn render<'reg: 'rc, 'rc>(
670-
&'rc self,
671-
registry: &'reg Registry<'reg>,
672-
ctx: &'rc Context,
673-
rc: &mut RenderContext<'reg, 'rc>,
674-
out: &mut dyn Output,
675-
) -> Result<(), RenderError> {
676-
render_helper(self, registry, ctx, rc, out)
677-
}
678-
}
679-
680668
impl Renderable for Template {
681669
fn render<'reg: 'rc, 'rc>(
682670
&'rc self,

0 commit comments

Comments
 (0)