platform/packages/jael/jael_preprocessor/README.md

52 lines
1.8 KiB
Markdown
Raw Normal View History

2021-05-15 10:28:09 +00:00
# jael3_preprocessor
2021-05-18 12:12:47 +00:00
[![version](https://img.shields.io/badge/pub-v4.0.1-brightgreen)](https://pub.dartlang.org/packages/jael3_preprocessor)
2021-05-15 10:28:09 +00:00
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
[![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion)
[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/angel3/packages/jael/jael_preprocessor/LICENSE)
2017-10-02 15:46:00 +00:00
A pre-processor for resolving blocks and includes within
2021-05-15 10:28:09 +00:00
[Jael](https://github.com/dukefirehawk/angel/tree/angel3/packages/jael/jael) templates.
2017-10-02 15:46:00 +00:00
# Installation
In your `pubspec.yaml`:
```yaml
dependencies:
2021-05-15 10:28:09 +00:00
jael3_prepreprocessor: ^4.0.0
2017-10-02 15:46:00 +00:00
```
# Usage
It is unlikely that you will directly use this package, as it is
more of an implementation detail than a requirement. However, it
is responsible for handling `include` and `block` directives
(template inheritance), so you are a package maintainer and want
to support Jael, read on.
To keep things simple, just use the `resolve` function, which will
take care of inheritance for you.
```dart
2021-05-15 10:28:09 +00:00
import 'package:jael3_preprocessor/jael3_preprocessor.dart' as jael;
2017-10-02 15:46:00 +00:00
myFunction() async {
var doc = await parseTemplateSomehow();
var resolved = await jael.resolve(doc, dir, onError: (e) => doSomething());
}
```
You may occasionally need to manually patch in functionality that is not
available through the official Jael packages. To achieve this, simply
provide an `Iterable` of `Patcher` functions:
```dart
myOtherFunction(jael.Document doc) {
return jael.resolve(doc, dir, onError: errorHandler, patch: [
syntactic(),
sugar(),
etc(),
]);
}
```
**This package uses `package:file`, rather than `dart:io`.**