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

Support Multiple Templates in One Build Command #13

Closed
mtwichel opened this issue Nov 23, 2020 · 4 comments
Closed

Support Multiple Templates in One Build Command #13

mtwichel opened this issue Nov 23, 2020 · 4 comments
Assignees
Labels
question Further information is requested

Comments

@mtwichel
Copy link
Contributor

Motivation

I'm about to implement some templates into my Flutter app, but I ran into one little snag.

It would be super nice if you could specify multiple template files to build when writing your mason.yaml. For example, running mason build widget could generate view code and a test file.

We also may want to move where the vars property lives. I believe they are still bound to each template? If they were bound to a build command it would be easy to share them with multiple template files. Since mason.yaml is now required I don't think that's much of a stretch anyway.

If we're doing that, does it make sense to move all that metadata into a build command? I know we don't want to over-engineer the tool, but maybe it makes sense to keep the mason.yaml option available, but still pass in simple template.yaml files as well?

Example

mason.yaml

builds:
  greetings:
    description: A simple greeting in markdown.
    templates:
      - path: ./greetings.md
    vars:
      - name
  widget:
    description: A Flutter widget containing a view, bloc, and test scafold for the bloc.
    templates:
      - git:
          url: git@github.com:felangel/mason.git
          path: templates/widget/view_template.dart.txt
      - git:
          url: git@github.com:felangel/mason.git
          path: templates/widget/test_template.dart.txt
    vars:
      - name
      - generateBloc

YMK what you think. I'm happy to jump on a call to discuss, and happy to contribute the feature in a PR if you think it's a good direction to take things 🙂

@felangel
Copy link
Owner

Hey @mtwichel 👋
Thanks for opening an issue!

In this case, I would recommend having the view_template.dart and test_template.dart be part of the same widget template. The url of the template in this case would just point to the template.yaml which registers the vars and the __template__ itself can contain multiple files and subdirectories (for the view and test files).

Let me know if that helps and I'm happy to jump on a call as well to discuss further 👍

@felangel felangel self-assigned this Nov 23, 2020
@felangel felangel added the question Further information is requested label Nov 23, 2020
@mtwichel
Copy link
Contributor Author

@felangel Gotcha thanks. We may want to adjust the readme or examples to have that flow so people know it's possible, but that's great it is possible! 💯 🎉

@felangel
Copy link
Owner

yeah definitely! I'll add a more complex example shortly 👍

@felangel
Copy link
Owner

felangel commented Nov 23, 2020

Updated examples and docs in 92e4cf3

alestiago pushed a commit to alestiago/mason that referenced this issue Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants