replace_content 0.0.1

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 0

replace_content #

replace_content is a pub transformer that replaces the contents of some target files with the contents of matching source files based on the transformation mode.

Given a target file path/to/file.ext, its content will be replaced with the content of path/to/file.{mode}.ext where {mode} is the transformation mode passed to pub serve and pub build. path/to/file.{mode}.ext and other files of the same path format will be excluded from the rest of the build process.

The transformer has two parameters

  • targets: a list of target files or a single target file.
  • keep_source: whether source files should be kept. Default is false.

Usage #

Suppose that your project supports two transformation modes debug and release, and you want to change the contents of two target files based on the transformation mode. Those files are

  • lib/config.dart
  • web/sample.jpg

Your project should have these files

  • lib/config.dart: target file (text based)
  • lib/config.debug.dart: source file to use if mode is debug
  • lib/config.release.dart: source file to use if mode is release
  • web/sample.jpg: target file (binary)
  • web/sample.debug.jpg: source file to use if mode is debug
  • web/sample.release.jpg: source file to use if mode is release

In pubspec.yaml, add the transformer and specify the target files

transformers:
- replace_content:
    targets:
    - lib/config.dart
    - web/sample.jpg

After this transformer runs, the output will contain

  • lib/config.dart: contains the content of lib/config.debug.dart
  • web/sample.jpg: contains the content of web/sample.debug.jpg

Features and bugs #

Please file feature requests and bugs at the issue tracker.

Changelog #

0.0.1 #

  • Initial version, created by Stagehand

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  replace_content: ^0.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:replace_content/replace_content.dart';
  
Version Uploaded Documentation Archive
0.0.1 Feb 18, 2017 Go to the documentation of replace_content 0.0.1 Download replace_content 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
0
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.0.0 <2.0.0