MCPcopy Create free account
hub / github.com/Keats/tera / insert

Method insert

tera/src/context.rs:61–63  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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) {

Callers 15

criterion_benchmarkFunction · 0.80
uniqueFunction · 0.80
group_byFunction · 0.80
test_strFunction · 0.80
register_filterMethod · 0.80
register_testMethod · 0.80
register_functionMethod · 0.80
register_fromMethod · 0.80
finalize_templatesMethod · 0.80
add_raw_templatesMethod · 0.80
add_fileMethod · 0.80

Calls

no outgoing calls

Tested by 15

test_strFunction · 0.64
global_contextFunction · 0.64
can_get_kwarg_with_typeFunction · 0.64
context_macro_builderFunction · 0.64
can_iterate_on_graphemesFunction · 0.64
can_slice_on_graphemesFunction · 0.64
render_str_errorsFunction · 0.64
rendering_include_okFunction · 0.64