cooker 1.1.0
A template based file generator for Dart. You can use Cooker to generate source code (or not). Cooker support variables with flexible pattern.
cooker
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.
Usage
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
{{%s}}. - The variable value will be replaced on the
%sspace.
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.