A pre-processor for resolving blocks and includes within Jael templates.
In your pubspec.yaml
:
dependencies:
jael_prepreprocessor: ^1.0.0-alpha
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.
import 'package:jael_preprocessor/jael_preprocessor.dart' as jael;
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:
myOtherFunction(jael.Document doc) {
return jael.resolve(doc, dir, onError: errorHandler, patch: [
syntactic(),
sugar(),
etc(),
]);
}
This package uses package:file
, rather than dart:io
.
Patcher
signature for Dart 2 compatibility.example/main.dart
import 'dart:async';
import 'package:file/file.dart';
import 'package:jael/jael.dart' as jael;
import 'package:jael_preprocessor/jael_preprocessor.dart' as jael;
Future<jael.Document> process(
jael.Document doc, Directory dir, errorHandler(jael.JaelError e)) {
return jael.resolve(doc, dir, onError: errorHandler, patch: [
(doc, dir, onError) {
print(doc.root.children.length);
return doc;
},
]);
}
Add this to your package's pubspec.yaml file:
dependencies:
jael_preprocessor: "^1.0.0+1"
You can install packages from the command line:
with pub:
$ pub get
with Flutter:
$ flutter packages get
Alternatively, your editor might support pub get
or packages get
.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:jael_preprocessor/jael_preprocessor.dart';
Version | Uploaded | Documentation | Archive |
---|---|---|---|
1.0.0+1 | Apr 3, 2018 |
|
|
1.0.0 | Nov 28, 2017 |
|
|
1.0.0-alpha+2 | Oct 2, 2017 |
|
|
1.0.0-alpha+1 | Oct 2, 2017 |
|
|
1.0.0-alpha | Oct 1, 2017 |
|
|
We analyzed this package on Apr 23, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
6 | / 100 |
Health:
Code health derived from static analysis.
[more]
|
99 | / 100 |
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
100 | / 100 |
Overall score:
Weighted score of the above.
[more]
|
53 |
Detected platforms: Flutter, web, other
No platform restriction found in primary library
package:jael_preprocessor/jael_preprocessor.dart
.
Fix analysis and formatting issues.
Analysis or formatting checks reported 1 hint.
Run
dartfmt
to formatlib/jael_preprocessor.dart
.
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=1.19.0 <=2.0.0 | ||
file | ^2.0.0 | 2.3.7 | 5.0.0 |
jael | ^1.0.0-alpha | 1.0.4 | |
Transitive dependencies | |||
charcode | 1.1.1 | ||
code_buffer | 1.0.0 | ||
dart2_constant | 1.0.1+dart2 | ||
intl | 0.15.6 | ||
meta | 1.1.2 | ||
path | 1.5.1 | ||
source_span | 1.4.0 | ||
string_scanner | 1.0.2 | ||
symbol_table | 1.0.4 | ||
Dev dependencies | |||
test | ^0.12.0 |