Make code generator re-usable for other projects#434
Merged
Kijewski merged 1 commit intoaskama-rs:masterfrom May 17, 2025
Merged
Make code generator re-usable for other projects#434Kijewski merged 1 commit intoaskama-rs:masterfrom
Kijewski merged 1 commit intoaskama-rs:masterfrom
Conversation
Kijewski
commented
May 15, 2025
Comment on lines
-86
to
-87
| #[doc(hidden)] | ||
| pub use crate as shared; |
Member
Author
There was a problem hiding this comment.
Not needed since askama v0.10 IIRC.
ea15d1f to
81b64c4
Compare
This PR
* removes the crate `askama_derive_standalone`,
* makes `askama_derive` a normal library, and
* adds the proc-macro crate `askama_macros`,
Before, it was not possible for another crate to re-export
`askama::Template` in a useful way, because the generated code assumes
that it has access to an `extern crate askama`.
`askama_derive` will export the function `derive_template()` like
`askama_derive_standalone` did, but it has an additional argument to
accept a `TokenStream` that should contain (an) statement(s) to define
the identifier `askama`, e.g. `quote! { extern crate askama; }`.
The new proc-macro crate `askama_macros` now defines the derive-macro
`Template` by calling `askama_derive::derive_template()`.
Prior art: [`encase`] → [`encase_derive`] → [`encase_derive_impl`];
[2298a3e].
[`encase`]: <https://crates.io/crates/encase/0.11.0>
[`encase_derive`]: <https://crates.io/crates/encase_derive/0.11.0>
[`encase_derive_impl`]: <https://crates.io/crates/encase_derive_impl/0.11.0>
[2298a3e]: <teoxoy/encase@2298a3e>
GuillaumeGomez
approved these changes
May 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR
askama_derive_standalone,askama_derivea normal library, andaskama_macros,Before, it was not possible for another crate to re-export
askama::Templatein a useful way, because the generated code assumes that it has access to anextern crate askama.askama_derivewill export the functionderive_template()likeaskama_derive_standalonedid, but it has an additional argument to accept aTokenStreamthat should contain (an) statement(s) to define the identifieraskama, e.g.quote! { extern crate askama; }.The new proc-macro crate
askama_macrosnow defines the derive-macroTemplateby callingaskama_derive::derive_template().Prior art:
encase→encase_derive→encase_derive_impl; 2298a3e.The PR is best viewed with ignored whitespace changes.
Resolves #377.