pub struct HandlebarsChronoDateTime;Expand description
Chrono DateTime helper for Handlebars
§Registration
use chrono::Utc;
use handlebars::Handlebars;
use handlebars_chrono::HandlebarsChronoDateTime;
use serde_json::json;
let mut h = Handlebars::new();
h.register_helper("datetime", Box::new(HandlebarsChronoDateTime));
assert_eq!(h.render_template(r#"{{datetime}}"#, &json!({})).map(|s| s.as_str()[..16].to_string()).expect("Render error"), Utc::now().to_rfc3339().as_str()[..16].to_string());§Behavior
TODO
§Hash parameters
TODO
§Example usage:
Trait Implementations§
Source§impl Clone for HandlebarsChronoDateTime
impl Clone for HandlebarsChronoDateTime
Source§fn clone(&self) -> HandlebarsChronoDateTime
fn clone(&self) -> HandlebarsChronoDateTime
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl HelperDef for HandlebarsChronoDateTime
impl HelperDef for HandlebarsChronoDateTime
Source§fn call<'reg: 'rc, 'rc>(
&self,
h: &Helper<'rc>,
_r: &'reg Handlebars<'_>,
_ctx: &'rc Context,
_rc: &mut RenderContext<'reg, 'rc>,
out: &mut dyn Output,
) -> HelperResult
fn call<'reg: 'rc, 'rc>( &self, h: &Helper<'rc>, _r: &'reg Handlebars<'_>, _ctx: &'rc Context, _rc: &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<'rc>,
_: &'reg Registry<'reg>,
_: &'rc Context,
_: &mut RenderContext<'reg, 'rc>,
) -> Result<ScopedJson<'rc>, RenderError>where
'reg: 'rc,
fn call_inner<'reg, 'rc>(
&self,
_: &Helper<'rc>,
_: &'reg Registry<'reg>,
_: &'rc Context,
_: &mut RenderContext<'reg, 'rc>,
) -> Result<ScopedJson<'rc>, RenderError>where
'reg: 'rc,
A simplified api to define helper Read more
impl Copy for HandlebarsChronoDateTime
Auto Trait Implementations§
impl Freeze for HandlebarsChronoDateTime
impl RefUnwindSafe for HandlebarsChronoDateTime
impl Send for HandlebarsChronoDateTime
impl Sync for HandlebarsChronoDateTime
impl Unpin for HandlebarsChronoDateTime
impl UnwindSafe for HandlebarsChronoDateTime
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