jael_preprocessor 2.0.1

jael_preprocessor #

Pub build status

A pre-processor for resolving blocks and includes within Jael templates.

Installation #

In your pubspec.yaml:

dependencies:
  jael_prepreprocessor: ^1.0.0-alpha

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.

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.

2.0.1 #

  • Fixed a bug where failed file resolutions would not become proper errors.

2.0.0+1 #

  • Homepage update for Pub.

2.0.0 #

  • Dart 2 updates.
  • Fix a templating bug where multiple inheritance did not work.

1.0.0+1 #

  • Minor change to 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;
    },
  ]);
}

Use this package as a library

1. Depend on it

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


dependencies:
  jael_preprocessor: ^2.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:jael_preprocessor/jael_preprocessor.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
33
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
66
Learn more about scoring.

We analyzed this package on Aug 19, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: other

Primary library: package:jael_preprocessor/jael_preprocessor.dart with components: io, mirrors.

Health suggestions

Fix lib/jael_preprocessor.dart. (-0.50 points)

Analysis of lib/jael_preprocessor.dart reported 1 hint:

line 304 col 7: DO use curly braces for all flow control structures.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
file ^5.0.0 5.0.8+1
jael ^2.0.0 2.0.2
symbol_table ^2.0.0 2.0.0
Transitive dependencies
args 1.5.2
charcode 1.1.2
intl 0.15.8
meta 1.1.7
path 1.6.4
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
Dev dependencies
code_buffer any 1.0.1
test ^1.0.0