Implemented none and any, but I need to implement early termination.

master
Tom Alexander 4 years ago
parent f1b868ce33
commit 0fac063c8d
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

@ -100,3 +100,11 @@ Early termination stand-alone comparison{~n}
If your pet was a {type} we'd name it {pet_name}{~n}
{/pet_names}
{/select}{~n}
@any alone{~n}
=========={~n}
{@any}{person} has a pet!{~n}{/any}
@none alone{~n}
==========={~n}
{@none}I don't know what to name {person}'s pet...{~n}{/none}

@ -601,8 +601,40 @@ impl<'a> DustRenderer<'a> {
}
}
}
DustTag::DTHelperAny(parameterized_block) => todo!(),
DustTag::DTHelperNone(parameterized_block) => todo!(),
DustTag::DTHelperAny(parameterized_block) => match select_context {
Some(sc) if sc.were_any_true => {
let new_breadcrumbs = self.new_breadcrumbs_partial(
breadcrumbs,
breadcrumbs,
None,
&parameterized_block.explicit_context,
);
return self.render_maybe_body(
&parameterized_block.contents,
new_breadcrumbs.as_ref().unwrap_or(breadcrumbs),
blocks,
None,
);
}
_ => return Ok("".to_owned()),
},
DustTag::DTHelperNone(parameterized_block) => match select_context {
Some(sc) if !sc.were_any_true => {
let new_breadcrumbs = self.new_breadcrumbs_partial(
breadcrumbs,
breadcrumbs,
None,
&parameterized_block.explicit_context,
);
return self.render_maybe_body(
&parameterized_block.contents,
new_breadcrumbs.as_ref().unwrap_or(breadcrumbs),
blocks,
None,
);
}
_ => return Ok("".to_owned()),
},
}
Ok("".to_owned())

Loading…
Cancel
Save