Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use actual name of imported crate in generated code #803

Closed
Kijewski opened this issue Mar 29, 2023 · 2 comments
Closed

Use actual name of imported crate in generated code #803

Kijewski opened this issue Mar 29, 2023 · 2 comments

Comments

@Kijewski
Copy link
Collaborator

Using proc-macro-crate (or extracting its logic) it would be possible to emit e.g. ::askama_axum::… instead of ::askama::… if the user only used the integration crate instead of the parent one. Also, if the user renames the import like [dependencies] my_askama = { package = "askama" }, we could still generate working code.

The major drawback is that proc-macro-crate uses toml_edit which has a ton of dependencies. And actually in https://github.com/djc/askama/pull/780 we deliberately went away from using toml_edit for this exact reason. proc-macro-crate is only ~200 lines and liberally licensed as MIT OR Apache-2.0 like askama, so I guess we could simply extract or reproduce its logic using basic-toml. Is this case we would have to depend on serde, but chances are that any user of askama uses serde as well in their project.

We already depend on basic-toml & serde if the feature "config" is enabled.

@djc
Copy link
Collaborator

djc commented Mar 29, 2023

Hmm, I'm not convinced that's worth the added complexity.

@Kijewski
Copy link
Collaborator Author

Yeah, you're right. Users probably would even expect renamed dependencies to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants