Skip to main content

serializing_for_value

Function serializing_for_value 

Source
pub fn serializing_for_value() -> bool
Expand description

Function that returns true when serialization for Value is taking place.

When a value is converted through the Serde wrapper, MiniJinja uses the regular Serde serialization trait. In some cases users might want to customize that serialization for the template engine independently of what is normally serialized to disk.

This function returns true when MiniJinja is serializing to Value and false otherwise. You can call this within your own serde::Serialize implementation to change the output format.

This is particularly useful as serialization for MiniJinja does not need to support deserialization. So it becomes possible to completely change what gets sent there, even at the cost of serializing something that cannot be deserialized.