A template based file generator for Dart.
You can use Cooker to generate source code file (or not). Cooker also support variables with flexible pattern.
Bascic usage #
The usage can be very simple. Basically, you just need a template file path and a target file path.
import 'package:cooker/cooker.dart'; final templatePath = 'templates/template.md'; final targetPath = 'doc/doc.md'; final cooker = Cooker(templatePath, targetPath); cooker.generate();
Usage with variables #
The variables allows you to replace parts of text in the target file. You can enter a list of them and specify a pattern for replaces.
Some important notes:
- You can enter a variables pattern optionally. The default pattern is like
- The variable value will be replaced on the
import 'package:cooker/cooker.dart'; final templatePath = 'templates/template.md'; final targetPath = 'doc/doc.md'; final contentVariables = HashMap<String, String>(); contentVariables['author'] = 'danielxfr'; contentVariables['project'] = 'cooker'; final variablesPattern = '|%s|'; final cooker = Cooker(templatePath, targetPath, contentVariables: variables, variablesPattern: variablesPattern); cooker.generate();
This code will be work good in a template like this:
Hello, my friend. This is a |%s| project named as |%s|. You can see more about him on GitHub. Thanks for use this.
All notable changes to this project will be documented in this file.
[1.1.0] - 2019-12-12 #
- Usage documentation.
[1.0.2] - 2019-12-11 #
- Invalid return types as "void".
[1.0.1] - 2019-12-09 #
- pub.dev package compatibility.
[1.0.0] - 2019-12-09 #
First version with initial source code.
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies: cooker: ^1.1.0
2. Install it
You can install packages from the command line:
$ pub get
$ flutter pub get
Alternatively, your editor might support
pub get or
flutter pub get.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
We analyzed this package on Mar 24, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.7.1
- pana: 0.13.6
Health issues and suggestions
Document public APIs. (-1 points)
16 out of 16 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.
Maintain an example. (-10 points)
Create a short demo in the
example/ directory to show how to use this package.
Common filename patterns include
cooker.dart. Packages with multiple examples should provide
For more information see the pub package layout conventions.
|Dart SDK||>=2.0.0 <3.0.0|