pub struct IfNotEqualsHelper;
Expand description
Execute template if the first argument is not equal to all other arguments, otherwise execute the inverse (all arguments are converted to string and case insensitive compared)
//assert_eq!(
//exec_template(json!({}), r#"{{#if_not_equals "test" "teSt"}}{{else}}NOK{{/if_not_equals}}"#),
//"NOK"
//);
assert_eq!(
exec_template(json!({ "a": "42", "b": "42" }), r#"{{#if_not_equals a ./b }}{{else}}NOK{{/if_not_equals}}"#),
"NOK"
);
assert_eq!(
exec_template(json!({}), r#"{{#if_not_equals "test" "NO"}}OK{{else}}NOK{{/if_not_equals}}"#),
"OK"
);
assert_eq!(
exec_template(json!({}), r#"{{#if_not_equals "test" "NO" "NO" "test"}}OK{{else}}NOK{{/if_not_equals}}"#),
"NOK"
);
assert_eq!(
exec_template(json!({}), r#"{{#if_not_equals "test" "NO" "NOPE"}}OK{{else}}NOK{{/if_not_equals}}"#),
"OK"
);
Trait Implementations§
Source§impl HelperDef for IfNotEqualsHelper
impl HelperDef for IfNotEqualsHelper
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 IfNotEqualsHelper
impl RefUnwindSafe for IfNotEqualsHelper
impl Send for IfNotEqualsHelper
impl Sync for IfNotEqualsHelper
impl Unpin for IfNotEqualsHelper
impl UnwindSafe for IfNotEqualsHelper
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