From 68873d150a0e161c642fd43603f964ff4c86e8e7 Mon Sep 17 00:00:00 2001 From: Ivan Ganev Date: Sat, 20 Jul 2024 23:33:39 +0300 Subject: [PATCH] wip --- src/lib.rs | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f3449fe..c63df13 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -172,41 +172,30 @@ impl HelperDef for HandlebarsConcat { serde_json::Value::Bool(_) | serde_json::Value::Number(_) | serde_json::Value::String(_) => { - if h.is_block() && render_all { + let value = if h.is_block() && render_all { // use block template to render strings let mut content = StringOutput::default(); - let block = create_block(¶m); - rc.push_block(block); - + rc.push_block(create_block(¶m)); template .map(|t| t.render(r, ctx, rc, &mut content)) .unwrap_or(Ok(()))?; - rc.pop_block(); - if let Ok(out) = content.into_string() { - let result = if quotes { - format!("{}{}{}", quotation_mark, out, quotation_mark) - } else { - out - }; - - if !result.is_empty() && (!output.contains(&result) || !distinct) { - output.push(result); - } - } + content.into_string().unwrap_or_default() } else { - let mut value = param.value().render(); + param.value().render() + }; - if quotes { - value = format!("{}{}{}", quotation_mark, value, quotation_mark); - } + let value = if quotes { + format!("{}{}{}", quotation_mark, value, quotation_mark) + } else { + value + }; - if !output.contains(&value) || !distinct { - output.push(value); - } + if !value.is_empty() && (!output.contains(&value) || !distinct) { + output.push(value); } } serde_json::Value::Array(ar) => {