Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
iganev committed Jul 20, 2024
1 parent c91ddff commit 68873d1
Showing 1 changed file with 12 additions and 23 deletions.
35 changes: 12 additions & 23 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(&param);
rc.push_block(block);

rc.push_block(create_block(&param));
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) => {
Expand Down

0 comments on commit 68873d1

Please sign in to comment.