pub struct IfArrayContainsHelper;
Expand description
Write the template if the second argument is found in the array passed as first argument (values are compared with string insensitive comparison) (Pas completement fonctionnelle)
let json_array = json!({ "type": "object", "required": [ "errorMeSSage", "test" ], "properties": {"errorMessage": {"type": "string"}, "non_required_prop" : {"type" : "int"}}});
assert_eq!(
exec_template(json_array.clone(), r#"{{#if_array_contains required "errorMeSSage"}}OK{{else}}NOK{{/if_array_contains}}"#),
"OK"
);
//assert_eq!(
//exec_template(json_array.clone(), r#"{{#if_array_contains required "errormessage"}}OK{{else}}NOK{{/if_array_contains}}"#),
//"OK"
//);
assert_eq!(
exec_template(json_array.clone(), r#"{{#if_array_contains required "test"}}OK{{else}}NOK{{/if_array_contains}}"#),
"OK"
);
assert_eq!(
exec_template(json_array.clone(), r#"{{#if_array_contains required "notFound"}}OK{{else}}NOK{{/if_array_contains}}"#),
"NOK"
);
Trait Implementations§
Source§impl HelperDef for IfArrayContainsHelper
impl HelperDef for IfArrayContainsHelper
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 IfArrayContainsHelper
impl RefUnwindSafe for IfArrayContainsHelper
impl Send for IfArrayContainsHelper
impl Sync for IfArrayContainsHelper
impl Unpin for IfArrayContainsHelper
impl UnwindSafe for IfArrayContainsHelper
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