pub struct JsonHelper;
Expand description
Get the json representation of the first argument passed. If a second argument is true, the json is beautyfied
assert_eq!(
exec_template(json!(42), r#"{{json this}}"#),
"42"
);
assert_eq!(
exec_template(json!({"a": "42"}), r#"{{json this}}"#),
"{\"a\":\"42\"}"
);
assert_eq!(
exec_template(json!({"a": "42"}), r#"{{json this true}}"#),
"{\n \"a\": \"42\"\n}"
);
assert_eq!(
exec_template(json!(42), r#"{{json (json this)}}"#),
"\"42\""
);
Trait Implementations§
Source§impl HelperDef for JsonHelper
impl HelperDef for JsonHelper
Source§fn call_inner<'reg: 'rc, 'rc>(
&self,
h: &Helper<'reg, 'rc>,
_: &'reg Handlebars<'reg>,
_: &'rc Context,
_: &mut RenderContext<'reg, 'rc>,
) -> Result<ScopedJson<'reg, 'rc>, RenderError>
fn call_inner<'reg: 'rc, 'rc>( &self, h: &Helper<'reg, 'rc>, _: &'reg Handlebars<'reg>, _: &'rc Context, _: &mut RenderContext<'reg, 'rc>, ) -> Result<ScopedJson<'reg, 'rc>, RenderError>
A simplified api to define helper Read more
Auto Trait Implementations§
impl Freeze for JsonHelper
impl RefUnwindSafe for JsonHelper
impl Send for JsonHelper
impl Sync for JsonHelper
impl Unpin for JsonHelper
impl UnwindSafe for JsonHelper
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