Description
I would like to build a template engine that leverages custom derive to attach a template rendering function to a struct at compile time. I was planning on attaching an attribute to the struct to specify the path to the template file, which could then be read and transpiled into Rust. However, it seems it is currently not possible to get at the path to the source file where the TokenStream
originated. As such, it seems I would have to rely on absolute paths to template files or on the current working directory. Even assuming cargo compiles (including workspaces), this does not seem reliable.
The Item
s that are part of the TokenStream
contain a Span
, but I don't think the CodeMap
they index into is currently available to a proc_macro. Would that be a viable implementation strategy?