Closed benfrankel closed 1 month ago
Okay I found an approach that works:
Cargo.toml
into a Cargo.toml.template
(or w/e) with Liquid placeholders, and a Cargo.toml
with valid syntax."Cargo.toml.template"
to the include
list in cargo-generate.toml
(this can be "*.template"
so it only has to be added once).file::rename("Cargo.toml.template", "Cargo.toml");
to the post-generate hook.Oh, funny I was just strongly considering using sed
in a pre-commit lol... nice one.
This does mean that there will be 2 copies of each templated file that should be kept in sync, but that's a sacrifice I was prepared to make for a working solution anyways. Better than 2 branches of the entire repo :P
@BD103 if you feel like doing some CI magic at some point, we could issue a warning if a PR touches only one file when there exist both foo.rs
and foo.rs.template
👀
For example,
"{{project-name}}"
inCargo.toml
is not a valid crate name, so the template itself cannot be compiled. This makes it harder for maintainers of the template to make changes.Generated repos are not affected by this issue, only the template itself.