2021-09-13 00:30:02 +00:00
# Jael Ppreprocessor
2021-09-25 06:32:32 +00:00
![Pub Version (including pre-releases) ](https://img.shields.io/pub/v/jael3_preprocessor?include_prereleases )
2021-05-15 10:28:09 +00:00
[![Null Safety ](https://img.shields.io/badge/null-safety-brightgreen )](https://dart.dev/null-safety)
2024-07-07 15:02:49 +00:00
[![Discord ](https://img.shields.io/discord/1060322353214660698 )](https://discord.gg/3X6bxTUdCM)
2024-10-12 10:35:14 +00:00
[![License ](https://img.shields.io/github/license/dart-backend/protevus )](https://github.com/dart-backend/protevus/tree/master/packages/jael/jael_preprocessor/LICENSE)
2021-05-15 10:28:09 +00:00
2021-09-25 06:32:32 +00:00
A pre-processor for resolving blocks and includes within [Jael 3 ](https://pub.dev/packages/jael3 ) templates.
2017-10-02 15:46:00 +00:00
2021-09-13 00:30:02 +00:00
## Installation
2017-10-02 15:46:00 +00:00
In your `pubspec.yaml` :
```yaml
dependencies:
2023-05-26 23:27:47 +00:00
jael3_prepreprocessor: ^8.0.0
2017-10-02 15:46:00 +00:00
```
2021-09-13 00:30:02 +00:00
## Usage
2021-09-25 06:32:32 +00:00
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.
2017-10-02 15:46:00 +00:00
2021-09-25 06:32:32 +00:00
To keep things simple, just use the `resolve` function, which will take care of inheritance for you.
2017-10-02 15:46:00 +00:00
```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());
}
```
2021-09-25 06:32:32 +00:00
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:
2017-10-02 15:46:00 +00:00
```dart
myOtherFunction(jael.Document doc) {
return jael.resolve(doc, dir, onError: errorHandler, patch: [
syntactic(),
sugar(),
etc(),
]);
}
```
2021-09-13 00:30:02 +00:00
**This package uses `package:file` , rather than `dart:io` .**