Converts the `val` parameter to `Value` and insert it into the context. This can panic if the value cannot be serialised. ```rust # use tera::Context; let mut context = tera::Context::new(); context.insert("number_users", &42); ```
(&mut self, key: S, val: &T)
| 59 | /// context.insert("number_users", &42); |
| 60 | /// ``` |
| 61 | pub fn insert<S: Into<Cow<'static, str>>, T: Serialize + ?Sized>(&mut self, key: S, val: &T) { |
| 62 | self.data.insert(key.into(), Value::from_serializable(val)); |
| 63 | } |
| 64 | |
| 65 | /// In case you already have a `Value` you want to insert |
| 66 | pub fn insert_value<S: Into<Cow<'static, str>>>(&mut self, key: S, val: Value) { |
no outgoing calls