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

Template Generation #13

Open
spacekookie opened this issue Sep 15, 2018 · 4 comments
Open

Template Generation #13

spacekookie opened this issue Sep 15, 2018 · 4 comments

Comments

@spacekookie
Copy link
Contributor

Feature Request

Summary

There needs to be a better system in place to generate templates from snippets. This would allow us to generate templates on the fly for all sorts of crate configurations without having to keep all possible templates in files in the repo.

Motivation

Currently each template is just a file, which means that small changes to a template would require duplicating the entire file. This is very non-modular.

Drawbacks

If not done correctly it could result in quite unmaintainable code.

Unresolved Questions

  • Open discussion: are there any alternatives?
  • Do we store template snippets in files or generate those on the fly too?
  • And if working with snippet files: how small do we break them down?
  • Anything I've missed?
@yoshuawuyts
Copy link
Owner

This seems like a great idea!


Open discussion: are there any alternatives?

The goal is to be able to generate different outputs based on configuration. The only other alternative I can think of is using handlebars like templates (or macros), and using interpolation to fill in the blanks. The upside I would see to this approach is that it might make it easier to read.

The downside I see to this approach is that now the templates exist inline inside a macro, which comes with all the downsides of maintaining macros.


Do we store template snippets in files or generate those on the fly too?

Before continuing I think it would be useful to establish some terminology to reduce confusion:

  • template: a file that has some gaps that are filled with variables, snippets or partials.
  • snippet: a piece of a file, often dynamically generated, that is placed inside a template. Also referred to as "partial" in the handlebars world.

I would think that "templates" should be checked into source as-is, and we should probably generate the "snippets" ourselves. I'm not sure how much there would be to generating them, but probably some form of string concatenation would work well for most initial implementations.


And if working with snippet files: how small do we break them down?

Good question. I think this is probably something to be decided during implementation, if we go with snippets. If think this also applies when generating snippets dynamically.


Anything I've missed?

We can probably ask a few more questions:

  1. What would the API look like from the command line?
  2. What would the API look like for people using this as a lib?
  3. What would be a good first snippet to implement? (perhaps something like a "turn off clippy" or something?)

@stale
Copy link

stale bot commented Dec 16, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Dec 16, 2018
@spacekookie
Copy link
Contributor Author

Wtf?! This is really not a good bot when it comes to tracking issues 😩

@stale stale bot removed the wontfix This will not be worked on label Dec 16, 2018
@yoshuawuyts
Copy link
Owner

@spacekookie haha, yeah. There's some config possible, but haven't looked to deeply into it. Might be worth it tho.

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