1

I am using tera and want to make a CLI that acts as a new project generator (think rails scaffold). There will be quite a few templates and I would like to ship them in my crate as an asset file and read from disk instead of using include_str! and embedding the strings directly in the resulting binary.

Are there any crates that use this strategy that I could maybe reference? Is it possible to ship non-rust assets in a crate and have the referenced on disk later?

cafce25
  • 15,907
  • 4
  • 25
  • 31
Schneems
  • 14,918
  • 9
  • 57
  • 84
  • Might be worth looking at [`cargo generate`](https://crates.io/crates/cargo-generate) even if it doesn't use `tera`. – cafce25 Nov 28 '22 at 21:41
  • 1
    I took a look. It seems that cargo generate doesn't ship with any templates, you have to provide them yourself like `cargo generate cargo generate username-on-github/mytemplate` – Schneems Jan 10 '23 at 19:48
  • i'm surprised this is the only post i could find asking this question, it seems like a very common need to me ! why is there 0 traction on this ? – Inspi Feb 05 '23 at 17:48
  • I did ask on issues https://github.com/Keats/tera/issues/788 as well. It might be possible to hack something together with that other crate I mentioned there, but I've not tried. You might end up with a problem of detecting if you're in "development" or "crate/deployment" mode. – Schneems Feb 06 '23 at 21:52
  • I posted an issue on the cargo repos and got some answers that might help you ! https://github.com/rust-lang/cargo/issues/11683 – Inspi Feb 17 '23 at 11:49

0 Answers0