Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/juancastillo0/template_generator
Generate files from Dart code annotations and Mustache templates
https://github.com/juancastillo0/template_generator
code-generation dart dart-lang mustache mustache-templates template
Last synced: about 1 month ago
JSON representation
Generate files from Dart code annotations and Mustache templates
- Host: GitHub
- URL: https://github.com/juancastillo0/template_generator
- Owner: juancastillo0
- License: mit
- Created: 2022-08-13T20:40:26.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-08-14T05:10:09.000Z (about 2 years ago)
- Last Synced: 2024-10-03T13:20:11.287Z (about 1 month ago)
- Topics: code-generation, dart, dart-lang, mustache, mustache-templates, template
- Language: Dart
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
Generate files from Dart code annotations and [Mustache](http://mustache.github.io/) templates
## Features
- Generate files from Dart code annotations and [Mustache](http://mustache.github.io/) templates
## Getting started
Install dependencies:
```yaml
dev_dependencies:
build_runner:
mustache_generator:
git:
url: https://github.com/juancastillo0/template_generator
```## Usage
Create a Mustache template within the `lib` directory (`lib/templates/fieldsEnum.mustache`):
```mustache
enum {{name}}Fields {
{{# fields }}
{{ name }},
{{/ fields }}
}
```Create and annotate your model:
```dart
@FieldsEnumTemplate()
class Model {
final String fieldName;const Model({
required this.fieldName,
});
}
```Run the code generator:
```bash
dart pub run build_runner watch --delete-conflicting-outputs
```This will generate the following file:
```dart
enum ModelFields {
fieldName,
}
```You can check out the [`/example`](./example/) folder for a complete example.
## Additional information
TODO: Tell users more about the package: where to find more information, how to
contribute to the package, how to file issues, what response they can expect
from the package authors, and more.