-
-
Notifications
You must be signed in to change notification settings - Fork 139
Description
We currently depend on this crate for templating over at TensorZero. We are implementing a config snapshotting feature where we store the state of our config on startup so that historical inferences etc can be accurately reconstructed and replayed as they were. To do this, we wanted to capture all information including templates that could have been loaded by TensorZero.
Since minijinija allows loading from e.g. a PathLoader by import, include, or extends and these values can be dynamic, this is difficult to know since in principle an arbitrary file in the subdirectory PathLoader can access could be loaded or templated.
We implement a partial solution in this PR: to use the unstable_machinery feature and the exposed logic for parsing and walking an AST to find every import, include, and extend and figure out if the value being templated is static or dynamic. For our use case, it suffices to ban these dynamic imports (where a variable is substituted into an include) and gather a list of all paths that are imported from the file.
We believe the solution is satisfactory but of course would prefer not to depend on unstable code. I wanted to bring this to your awareness as requested in the documentation in case it is obvious to you how to do this without the unstable feature. Thanks for the great work with this crate!