Skip to main content

trillium_handlebars/
assigns.rs

1use serde::Serialize;
2use serde_json::Value;
3use std::{
4    borrow::Cow,
5    collections::HashMap,
6    ops::{Deref, DerefMut},
7};
8
9/// A struct for accumulating key-value data for use in handlebars
10/// templates. The values can be any type that is serde serializable
11#[derive(Default, Serialize, Debug)]
12pub struct Assigns(HashMap<Cow<'static, str>, Value>);
13
14impl Deref for Assigns {
15    type Target = HashMap<Cow<'static, str>, Value>;
16
17    fn deref(&self) -> &Self::Target {
18        &self.0
19    }
20}
21
22impl DerefMut for Assigns {
23    fn deref_mut(&mut self) -> &mut Self::Target {
24        &mut self.0
25    }
26}