Generating multiple files from a `list` type
- Dominant language
- Dart
- Stars
- 1.1k
- Forks
- 113
- PR merge metrics
- No merged PRs in 30d
Description
Hi!
I have this question about generating a list of files, but after search on docs and other issues, I think this is not implemented. Or maybe I do it in the wrong way... π€
I create this bug as a bug, but feel free to label it correctly if I miss something.
**Description**
I want to generate a list of files, from a `list` param in the `brick.yaml` file. This will allow the user of the brick to generate multiple files with the same logic inside.
For example, we want to generate multiple models from a brick called `generate_data_models`, with the following `brick.yaml` file:
```yaml
name: generate_data_models
description: Creates a new data models
version: 0.1.0+1
environment:
mason: ">=0.1.0-dev.51 <0.1.0"
vars:
data_folder_name:
type: string
description: Name of the data folder to put the model files inside.
prompt: What is the data folder name?
models:
type: list
description: List of models, used to create basic model class files.
prompt: What are the models names to create (separated by comma)?
separator: ","
```
And the following brick tree:
```sh
.
βββ CHANGELOG.md
βββ LICENSE
βββ README.md
βββ __brick__
β βββ lib
β βββ data
β βββ {{data_folder_name.snakeCase()}}
β βββ data
β β βββ data.dart
β βββ models
β β βββ models.dart
β β βββ {{#models}}{{..snakeCase()}}.dart{{
β β βββ models}}
β βββ {{data_folder_name.snakeCase()}}.dart
βββ brick.yaml
```
When I generate the code from this brick, this will create the following tree (inspired by the [Weather tuturial](https://bloclibrary.dev/#/flutterweathertutorial)):
```sh
lib/data
βββ open_meteo_api
βββ data
β βββ data.dart
βββ models
β βββ location.dartweather.dart
β βββ models.dart
βββ open_meteo_api.dart
```
The expected output will be two separated files generated for `location` & `weather`:
```sh
lib/data
βββ open_meteo_api
βββ data
β βββ data.dart
βββ models
β βββ location.dart
β βββ models.dart
β βββ weather.dart
βββ open_meteo_api.dart
```
Plus, inside each file we want to access to the current `model` to generate the relevant code class code for this model.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.