pub struct DistinctiveHelper { /* private fields */ }
Expand description
Execute template if the first argument is equal to any other argument, otherwise execute the inverse (all arguments are converted to string and case insensitive compared)
assert_eq!(
exec_template(json!({ "a": "42", "b": "42" }), r#"{{#each this}}{{@key}}/{{this}} {{/each}}"#),
"a/42 b/42 "
);
assert_eq!(
exec_template(json!({ "a": "42", "b": "42" }), r#"{{#each this}}{{#distinctive "values" this}}{{@key}}/{{this}} {{/distinctive}}{{/each}}"#),
"a/42 "
);
Trait Implementations§
Source§impl Default for DistinctiveHelper
impl Default for DistinctiveHelper
Source§fn default() -> DistinctiveHelper
fn default() -> DistinctiveHelper
Returns the “default value” for a type. Read more
Source§impl HelperDef for DistinctiveHelper
impl HelperDef for DistinctiveHelper
Source§fn call<'reg: 'rc, 'rc>(
&self,
h: &Helper<'reg, 'rc>,
handle: &'reg Handlebars<'reg>,
ctx: &'rc Context,
render_ctx: &mut RenderContext<'reg, 'rc>,
out: &mut dyn Output,
) -> HelperResult
fn call<'reg: 'rc, 'rc>( &self, h: &Helper<'reg, 'rc>, handle: &'reg Handlebars<'reg>, ctx: &'rc Context, render_ctx: &mut RenderContext<'reg, 'rc>, out: &mut dyn Output, ) -> HelperResult
A complex version of helper interface. Read more
Source§fn call_inner<'reg, 'rc>(
&self,
_: &Helper<'reg, 'rc>,
_: &'reg Registry<'reg>,
_: &'rc Context,
_: &mut RenderContext<'reg, 'rc>,
) -> Result<ScopedJson<'reg, 'rc>, RenderError>where
'reg: 'rc,
fn call_inner<'reg, 'rc>(
&self,
_: &Helper<'reg, 'rc>,
_: &'reg Registry<'reg>,
_: &'rc Context,
_: &mut RenderContext<'reg, 'rc>,
) -> Result<ScopedJson<'reg, 'rc>, RenderError>where
'reg: 'rc,
A simplified api to define helper Read more
Auto Trait Implementations§
impl !Freeze for DistinctiveHelper
impl RefUnwindSafe for DistinctiveHelper
impl Send for DistinctiveHelper
impl Sync for DistinctiveHelper
impl Unpin for DistinctiveHelper
impl UnwindSafe for DistinctiveHelper
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more