Skip to content
Discussion options

You must be logged in to vote

Not like this. If you work with objects via ViaDeserialize minijinja will need the type information carried side by side like this. However if your objects like PhoneNumber, Currency etc. were to implement Object then you could pass it as Value::from_object(...) to the context and pass it as Value to the filter:

use std::fmt;
use std::sync::Arc;

use minijinja::value::{Object, ObjectRepr};
use minijinja::{context, Environment, Value};

#[derive(Debug)]
struct PhoneNumber {
    digits: Vec<u8>,
}

impl Object for PhoneNumber {
    fn repr(self: &Arc<Self>) -> ObjectRepr {
        ObjectRepr::Plain
    }

    fn render(self: &Arc<Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        w…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ZakSingh
Comment options

Answer selected by ZakSingh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants