String macro expansion crate

Say I have a string which looks like “Hello, ${NAME}”, and I have a <String, String> HashMap which contains “NAME” = “Frank Foobar”, then I want to be able to call a magic function to transform, the string to “Hello, Frank Foobar”. But I also need different lookup backends (i.e. not only a hashmap; could look up using environment variables, or even some logic which uses environment variables if they exist and fall back to a hashmap otherwise). Must resolve iteratively and detect circular references.

Anyone know of such a crate?

Sounds like you’re looking for a templating engine, there are [a lot of them available on crates.io].

1 Like