Closed Folyd closed 1 year ago
The context itself is abstracted away in MiniJinja. On the input side anything that is Serialize
can become the source of a context, within the template runtime model (eg: filters, functions and more) you can indirectly access the context via State.
In your case it sounds like you just need to define a type for yourself that implements Serialize
that you can use (eg: a HashMap<String, Value>
for instance.
Thanks, @mitsuhiko. HashMap<String, Value>
is fair enough, that's what the tera::Context
did in the nutshell. It would be better if minijinja
can provide an off-the-shelf Context
API.
I'm not entirely sure what the point of this is. Can you outline how a context API helps? For what it's worth MiniJinja constructs just a BTreeMap
when you use the context!
macro for instance, but that's all hidden from a user as there does not seem to be much of a reason to expose it.
I will close this because I do not believe there to be value in adding this. There might be reasons for it, but so far I haven't been convinced that it would add anything.
I'm investigating how to migrate from
tera
tominijinja
. https://github.com/zineland/zine/issues/109 However,minijinja
lacks a goodContext
API like thetera::Context
which my project relied on heavily.https://github.com/zineland/zine/blob/master/src/entity/mod.rs#L32-L40