Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement cargo project templates #1747
Conversation
rust-highfive
assigned
huonw
Jun 25, 2015
This comment has been minimized.
This comment has been minimized.
rust-highfive
commented
Jun 25, 2015
|
r? @huonw (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
|
Also to note, this converts the standard |
This comment has been minimized.
This comment has been minimized.
|
It's also a bit rough around the edges. Let me know where you think I can improve it! |
gchp
reviewed
Jun 25, 2015
| @@ -159,7 +159,7 @@ impl GitRemote { | |||
| } | |||
|
|
|||
| impl GitDatabase { | |||
| fn path<'a>(&'a self) -> &'a Path { | |||
| pub fn path<'a>(&'a self) -> &'a Path { | |||
This comment has been minimized.
This comment has been minimized.
gchp
Jun 25, 2015
Author
Contributor
Whoops, I meant to revert the changes to this file, will update!
gchp
added some commits
Jun 26, 2015
alexcrichton
assigned
alexcrichton
and unassigned
huonw
Jun 29, 2015
This comment has been minimized.
This comment has been minimized.
|
Whoa, nice! I'm quite excited to see some progress on this front :) Some thoughts of mine:
I think it'd also be worth looking into other package managers to see what they do here. For example how does this compare to bundler's template integration (or is it Rails that has templates over there?). Also cc @wycats, I'm sure you'll have many opinions on this! |
This comment has been minimized.
This comment has been minimized.
|
Also cc @rust-lang/tools, you'll probably all in general be interested in this. |
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton thanks for the comments! I figured this would spark some discussion, but wanted to get an initial draft done to kickstart it.
I know that Django has support for project templates, but I'll check out a few similar solutions and see how they approach it. I'll update this PR as I go. Looking forward to more feedback! |
This comment has been minimized.
This comment has been minimized.
|
I chatted with @wycats on IRC and he mentioned that handlebars may be more appropriate as a templating language (I'm personally unfamiliar with both), but I just want to make sure that we consider other possibilities. I'm also not 100% sure about what to do on the update front, so I'm curious what other projects do in this regard. To match cargo's existing behavior then |
This comment has been minimized.
This comment has been minimized.
|
I'm obviously biased about Handlebars, but it's basically 98% compatible with Mustache but also supports helpers exposed by the host language. In contrast, Mustache supports loops and conditionals. |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
gsingh93
commented
Jul 10, 2015
|
Having the template download/update commands be separate from the project initialization command makes more sense to me. It feels weird to first specify a URL with |
This comment has been minimized.
This comment has been minimized.
|
Sorry for the delay on updating this, working on tests at the moment, then switching over the handlebars per the comments from @wycats. Hopefully get that part done in the next few days! Another possibility for managing templates would be to just not store them at all. Just download the one you want, scaffold the project, then remove the template. Next time you want it, repeat the process. Just s thought... |
This comment has been minimized.
This comment has been minimized.
|
So, just did some digging into how the It downloads templates to a temporary directory, which will get removed after use. You can also point it at a local folder, which obviously won't download anything. This is a better approach I think. It means that templates won't go out of date, because you need to re-download them every time you want them. If you find yourself re-using a template multiple times then you can download it yourself and point cargo at that each time instead. This changes the responsibility for managing the templates to the user, rather than cargo itself. What do you think of that approach? |
This comment has been minimized.
This comment has been minimized.
|
Sounds like a good idea to me! |
This comment has been minimized.
This comment has been minimized.
|
Closing due to inactivity, but feel free to reopen with a rebase and comments addressed! |
alexcrichton
closed this
Nov 16, 2015
killercup
referenced this pull request
Apr 25, 2016
Closed
Prepopulate examples and tests directories #2613
This comment has been minimized.
This comment has been minimized.
|
This was closed due to inactivity. It's almost a year old so I expect rebasing is not an option. Are there any other options for resurrecting it? It's a really useful project! |
This comment has been minimized.
This comment has been minimized.
|
Yeah unfortunately this'll need to go through a rebase or start from scratch. |
gchp commentedJun 25, 2015
Project templates allow users to define custom templates which can be
used to scaffold projects. These templates consists of a directory of
files, each of which will be treated as a mustache template.
Example:
This would download the template called 'nickel-template' to
~/.cargo/templates/nickel-template. Each file in that directory would
then be compiled and rendered to the new project directory created by
cargo. Once the template is downloaded, future uses can just reference
it by name:
Certain files will be ignored in template directories. These are namely
files which mustache will not be able to compile. Image files, for
example are all ignored.
Closes issue #396