Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
iganev committed Jul 24, 2024
1 parent 743e31c commit c6441dd
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,16 @@ impl HelperDef for HandlebarsConcat {
",".to_string()
};

// filter output
let distinct = h.hash_get("distinct").is_some();

// enable quotation marks wrapping
let quotes = h.hash_get("quotes").is_some();
let single_quote = h.hash_get("single_quote").is_some(); // as a modifier on top of "quotes", switches to single quotation

let quotation_mark = if quotes {
// as a modifier on top of "quotes", switches to single quotation
let single_quote = h.hash_get("single_quote").is_some();

let wrapper = if quotes {
if single_quote {
QUOTES_SINGLE
} else {
Expand Down Expand Up @@ -196,7 +200,7 @@ impl HelperDef for HandlebarsConcat {
param.value().render()
};

let value = apply_wrapper(value, quotation_mark, quotes);
let value = apply_wrapper(value, wrapper, quotes);

if !value.is_empty() && (!output.contains(&value) || !distinct) {
output.push(value);
Expand All @@ -222,7 +226,7 @@ impl HelperDef for HandlebarsConcat {
rc.pop_block();

if let Ok(value) = content.into_string() {
let value = apply_wrapper(value, quotation_mark, quotes);
let value = apply_wrapper(value, wrapper, quotes);

if !value.is_empty() && (!output.contains(&value) || !distinct) {
output.push(value);
Expand All @@ -234,7 +238,7 @@ impl HelperDef for HandlebarsConcat {
&mut ar
.iter()
.map(|item| item.render())
.map(|item| apply_wrapper(item, quotation_mark, quotes))
.map(|item| apply_wrapper(item, wrapper, quotes))
.filter(|item| {
if distinct {
!output.contains(item)
Expand Down Expand Up @@ -266,7 +270,7 @@ impl HelperDef for HandlebarsConcat {
rc.pop_block();

if let Ok(value) = content.into_string() {
let value = apply_wrapper(value, quotation_mark, quotes);
let value = apply_wrapper(value, wrapper, quotes);

if !value.is_empty() && (!output.contains(&value) || !distinct) {
output.push(value);
Expand All @@ -280,7 +284,7 @@ impl HelperDef for HandlebarsConcat {
&mut o
.keys()
.cloned()
.map(|item| apply_wrapper(item, quotation_mark, quotes))
.map(|item| apply_wrapper(item, wrapper, quotes))
.filter(|item| {
if distinct {
!output.contains(item)
Expand Down

0 comments on commit c6441dd

Please sign in to comment.