minijinja::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.

MiniJinja internally creates Value objects from all values passed to the engine. It does this by going through the regular serde serialization trait. In some cases users might want to customize the serialization specifically for MiniJinja because they want to tune the object 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 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.