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

Namespaced templates #4039

Closed
snoyberg opened this issue May 24, 2018 · 13 comments
Closed

Namespaced templates #4039

snoyberg opened this issue May 24, 2018 · 13 comments

Comments

@snoyberg
Copy link
Contributor

Problem There is no clear criteria right now for which templates should be included in the stack-templates repo. No one person has control over this repo, making it difficult for tutorial authors to rely on it in their documentation. The output of stack templates can be overwhelming.

Proposed solution Introduce namespacing into the template concept. There definitely room to modify this, but as an initial proposal that keeps backwards compatibility, let's consider:

  • A template name github:username/template can be found on the repo https://github.com/username/stack-templates, on the master branch, in the file template.hsfiles
  • The github: leader is for future proofing, if someone wants to add support for Gitlab, Bitbucket, or others
  • If github: is left off, it is filled in automatically, so that username/template is treated as github:username/template
  • Similarly, if the username namespacing is left off, e.g. template, the assumed username is commercialhaskell, falling back to the current behavior

Then, as an example, the Yesod templates could end up being referred to as yesodweb/postgres, etc.

To deal with the overwhelming output from stack templates: what if we have a README.md or similar file in commercialhaskell/stack-templates which is downloaded and displayed to the user explaining a few of the common templates, and then pointing to a Wiki page or similar where people can share more templates.

@SkyWriter
Copy link
Member

I love the idea! This would also address the problem of the templates being hardly documented. Wiki is a media rich enough to help steering in the fogs.

@Blaisorblade
Copy link
Collaborator

FWIW, SBT also uses Github-based namespacing for templates, I’ve never heard complaints (unlike other features) and there seems to be quite some support for it: https://www.scala-sbt.org/1.0/docs/sbt-new-and-Templates.html.
Also FWIW: those templates are entire repos (which makes them a bit easier to navigate than packing all files in a repo, and allows having separate repos in a single organization), and discovery also happens elsewhere.

@SkyWriter
Copy link
Member

Having a whole repo dedicated to a template sounds like a reasonable option to me.

@snoyberg
Copy link
Contributor Author

I didn't mention it in the initial bit, but I'm not opposed to moving beyond the hsfiles system to something like whole-repo systems. We'd have to figure out appropriate naming to make it all work nicely, and how to do variable replacement, but I don't see anything insurmountable. But I'd rather focus on fixing the biggest concerns people are raising first, especially since it should be a relatively minor amount of code.

@SkyWriter
Copy link
Member

I think I can get my hands dirty with this issue. Was just looking around to get some more Haskell in my systems.

@snoyberg
Copy link
Contributor Author

Awesome, go for it @SkyWriter!

@alexanderkjeldaas
Copy link
Contributor

alexanderkjeldaas commented May 25, 2018

It seems like some of the discussion lately has been that the templates are all different and it's unclear which to use. Github repos have some metrics that can help:

  • Last commit date (how stale is it)
  • Number of stars

@nh2
Copy link
Collaborator

nh2 commented Jun 3, 2018

A template name github:username/template can be found on the repo https://github.com/username/stack-templates, on the master branch, in the file template.hsfiles

Maybe I'm missing something, but why go for the short syntax of github:username/template instead of just using URLs directly?

I'd even find that more convenient, if I can directly copy them in from my browser or the other way around.

Or is the idea here that you'd actually type these characters down, so we'd like them to be short?

@snoyberg
Copy link
Contributor Author

snoyberg commented Jun 3, 2018 via email

@SkyWriter
Copy link
Member

Maybe I'm missing something, but why go for the short syntax of github:username/template instead of just using URLs directly?

Also, full URLs are already supported.

@nh2
Copy link
Collaborator

nh2 commented Jun 11, 2018

OK, makes sense!

@snoyberg
Copy link
Contributor Author

Addressed by #4103

@SkyWriter
Copy link
Member

Darn, missed it by just a couple o' days! Anyways, glad it's landed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants