cooker 1.1.0 copy "cooker: ^1.1.0" to clipboard
cooker: ^1.1.0 copied to clipboard

A template based file generator for Dart. You can use Cooker to generate source code (or not). Cooker support variables with flexible pattern.

cooker #

pub.dev

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:

  1. You can enter a variables pattern optionally. The default pattern is like {{%s}}.
  2. The variable value will be replaced on the %s space.
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.
0
likes
20
pub points
0%
popularity

Publisher

unverified uploader

A template based file generator for Dart. You can use Cooker to generate source code (or not). Cooker support variables with flexible pattern.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

More

Packages that depend on cooker