Use StructObject For Dynamic Variables In Rust's MiniJinja
Code
use crate Page;
use ;
use ;
Code
use ;
use ;
use ;
;
;
Notes
needs `cargo add minijinja serde``
needs `derive`` added to `serde`` in _Cargo.toml__ like:
``` serde = {version = "1.0.177", features = ["derive"] } ```
If you try to just print the main object out in the template (e.g. with `{{ whatever }}`` and don't call a function on it nothing will show up. Makes sense, but it threw me the first couple of times
The old notes had `#[serde(content = "content", rename_all = "lowercase", tag = "type")]`` but I think that causes a problem with enums with a single value (i.e. not struct enums, but I forget what the other ones are called)
-
Combine these two examples with .from and .from_seriliazble
-
Combine with 2vauitbb
-
Show regular object which allows method calls and is the way to go with neopoligin
References
-
This is the key to being able to use functions from object inside templates