pub struct IfNotEmptyHelper;
Expand description
Call the template if a non empty or whitespaces string is passed as parameter, or any other non null value
assert_eq!(
exec_template(json!({}), "{{#if_not_empty 42}}OK{{else}}NOK{{/if_not_empty}}"),
"OK"
);
assert_eq!(
exec_template(json!({}), "{{#if_not_empty \"42\"}}OK{{else}}NOK{{/if_not_empty}}"),
"OK"
);
assert_eq!(
exec_template(json!({}), "{{#if_not_empty \" \"}}OK{{else}}NOK{{/if_not_empty}}"),
"NOK"
);
assert_eq!(
exec_template(json!({}), "{{#if_not_empty not_existing}}OK{{else}}NOK{{/if_not_empty}}"),
"NOK"
);
assert_eq!(
exec_template(json!({"plop": "plop"}), "{{#if_not_empty plop}}OK{{else}}NOK{{/if_not_empty}}"),
"OK"
);
assert_eq!(
exec_template(json!({"plop": ""}), "{{#if_not_empty plop}}OK{{else}}NOK{{/if_not_empty}}"),
"NOK"
);
assert_eq!(
exec_template(json!({"plop": "plop"}), "{{#if_not_empty not_existing}}OK{{else}}NOK{{/if_not_empty}}"),
"NOK"
);
Trait Implementations§
Source§impl HelperDef for IfNotEmptyHelper
impl HelperDef for IfNotEmptyHelper
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 IfNotEmptyHelper
impl RefUnwindSafe for IfNotEmptyHelper
impl Send for IfNotEmptyHelper
impl Sync for IfNotEmptyHelper
impl Unpin for IfNotEmptyHelper
impl UnwindSafe for IfNotEmptyHelper
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