-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
Request for feedback on Template Modules beta #151
Comments
Here are some things I want to improve (feedback welcome on all these points). Template Builder for Shared moduleI'd like to have an API for building up Better developer experience for the TemplateType and variantsRight now, users have to manually add a variant, with exactly 1 argument, for every module in One nice improvement might be to generate
Planned improvements
|
Great work! 💪 I really like the idea of the Template Modules, and how it can make things so much more streamlined. One bug that I've found from initially playing around with the
My assumption is that What is confusing about the initial setup? |
Oh good catch on the wildcard Yeah, unfortunately I don't think it's possible to define the Metadata types directly in the Template Module and let that be the source of truth. But I'm thinking it would work pretty nicely to just have a single module where you define only the types, and then auto-generate the custom type variants based on that. Something like module TemplateData exposing (..)
import Time
type alias Article = { title : String, publishDate : Time.Posix }
type alias Page = { title : String, description : String }
-- ... other types here
-- one for each module in `src/Template` Then I can automatically generate the custom type. I could even include it in the generated code in module Template exposing (..)
import TemplateData
type Data
= Article TemplateData.Article
| Page TemplateData.Page |
This is super interesting! 🧐 Based on your example, I'm wondering if the For example, running
You could then just edit this if you want. Maybe there are also CLI flags for It's pretty interesting what you could do based on these Maybe in the future there could be a |
Generating the custom type and variants is feeling like a pretty clear win, so I'm looking forward to building that soon and seeing how it feels. I've thought about the generate command for different variations of builder, too. It's an interesting one, because with the builder pattern, it's set up to be able to easily add things in as needed. But that said, I think it's still useful to have both (that is, a builder pattern to easily transition, and generator helpers to easily initialize with different permutations). My thinking on generating a starting point for the TemplateData type aliases is that I try to avoid touching user-maintained files when I do code gen, even if it's just adding something to it. And in this case, it doesn't buy the user much because they still are going to need to change the type anyway. I'm thinking that it would be awesome to have a way to give really good error messages to direct the user to exactly what's wrong.
There's no great way to export types in pure Elm, but fortunately we do control the compilation process, so we can guarantee that the user will see that message and give them more nuanced information and guidance.
I've thought about |
Helpful error messages would be really beneficial. I think that would be a nice onboarding process when a user starts to add Template files to avoid confusion. A way of educating how
Yeah, I see what you mean. Ultimately that’s more helpful than an opinionated built-in starter repo. |
I think this feature is almost ready to lose the term "Beta" and turn into a standard feature! Progress so far: Done
TODO Before Template Modules Release Candidate
Future iteration
Other feedback?I'm still looking to hear people's thoughts and experiences with this, so feel free to comment and continue the discussion here! |
Release Candidate ProcessJust to clarify a few things, this is what I'm envisioning for doing a release candidate for Template Modules.
|
Sounds great 💪 |
All the good stuff I learned from this experiment has now made its way into the 2.0 release! 🎉 Thanks for all the good feedback! |
I need to go through a few more iterations before Template Modules are ready to go out of beta. I need feedback to get to that point, and I would love to hear any ideas in this thread!
Trying out the Template Modules beta
You can upgrade your current app to use the Template Modules beta using these instructions: https://github.com/dillonkearns/elm-pages/blob/master/docs/7.0.0-elm-package-upgrade-guide.md#3---beta-template-modules-feature.
Or you can try out the
template-modules
branch in theelm-pages-starter
repo.Note that there is a command to generate a simple scaffolded Template Module. You can run
npx elm-pages-generate Recipe
, for example, to build a scaffold atsrc/Template/Recipe.elm
.What kind of feedback do I need?
I'd love to hear both what is working well and what could be improved. Thanks for any and all feedback!
The text was updated successfully, but these errors were encountered: