angel_jael 1.0.3

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 45

jael

Pub build status

Angel support for Jael.

Installation

In your pubspec.yaml:

dependencies:
  angel_jael: ^1.0.0-alpha

Usage

Just like mustache and other renderers, configuring Angel to use Jael is as simple as calling app.configure:

import 'package:angel_framework/angel_framework.dart';
import 'package:angel_jael/angel_jael.dart';
import 'package:file/file.dart';

AngelConfigurer myPlugin(FileSystem fileSystem) {
    return (Angel app) async {
        // Connect Jael to your server...
        await app.configure(
        jael(fileSystem.directory('views')),
      );
    };
}

package:angel_jael supports caching views, to improve server performance. You might not want to enable this in development, so consider setting the flag to app.isProduction:

jael(viewsDirectory, cacheViews: app.isProduction);

Keep in mind that this package uses package:file, rather than dart:io.

The following is a basic example of a server setup that can render Jael templates from a directory named views:

import 'package:angel_framework/angel_framework.dart';
import 'package:angel_jael/angel_jael.dart';
import 'package:file/local.dart';
import 'package:logging/logging.dart';

main() async {
  var app = new Angel();
  var fileSystem = const LocalFileSystem();

  await app.configure(
    jael(fileSystem.directory('views')),
  );

  // Render the contents of views/index.jl
  app.get('/', (res) => res.render('index', {'title': 'ESKETTIT'}));

  app.use(() => throw new AngelHttpException.notFound());

  app.logger = new Logger('angel')
    ..onRecord.listen((rec) {
      print(rec);
      if (rec.error != null) print(rec.error);
      if (rec.stackTrace != null) print(rec.stackTrace);
    });

  var server = await app.startServer(null, 3000);
  print('Listening at http://${server.address.address}:${server.port}');
}

To apply additional transforms to parsed documents, provide a set of patch functions, like in package:jael_preprocessor.

1.0.3

  • Update for annoying map casting bug.

1.0.2

  • Update for DSX support.
  • Clear the buffer on errors.

1.0.1

  • Use Renderer.errorDocument.

example/main.dart

import 'package:angel_framework/angel_framework.dart';
import 'package:angel_jael/angel_jael.dart';
import 'package:dart2_constant/convert.dart';
import 'package:file/local.dart';
import 'package:logging/logging.dart';

main() async {
  var app = new Angel()..lazyParseBodies = true;
  var http = new AngelHttp(app);
  var fileSystem = const LocalFileSystem();

  await app.configure(
    jael(fileSystem.directory('views')),
  );

  app.get('/',
      (res) => res.render('index', {'title': 'Sample App', 'message': null}));

  app.post('/', (RequestContext req, res) async {
    var body = await req.lazyBody();
    print('Body: $body');
    var msg = body['message'] ?? '<unknown>';
    return await res.render('index', {
      'title': 'Form Submission',
      'message': msg,
      'json_message': json.encode(msg),
    });
  });

  app.use(() => throw new AngelHttpException.notFound());

  app.logger = new Logger('angel')
    ..onRecord.listen((rec) {
      print(rec);
      if (rec.error != null) print(rec.error);
      if (rec.stackTrace != null) print(rec.stackTrace);
    });

  var server = await http.startServer(null, 3000);
  print('Listening at http://${server.address.address}:${server.port}');
}

Use this package as a library

1. Depend on it

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


dependencies:
  angel_jael: ^1.0.3

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:angel_jael/angel_jael.dart';
  
Version Uploaded Documentation Archive
1.0.3 Jul 14, 2018 Go to the documentation of angel_jael 1.0.3 Download angel_jael 1.0.3 archive
1.0.2 Jun 26, 2018 Go to the documentation of angel_jael 1.0.2 Download angel_jael 1.0.2 archive
1.0.1 Apr 3, 2018 Go to the documentation of angel_jael 1.0.1 Download angel_jael 1.0.1 archive
1.0.0 Nov 28, 2017 Go to the documentation of angel_jael 1.0.0 Download angel_jael 1.0.0 archive
1.0.0-alpha+2 Oct 16, 2017 Go to the documentation of angel_jael 1.0.0-alpha+2 Download angel_jael 1.0.0-alpha+2 archive
1.0.0-alpha+1 Oct 2, 2017 Go to the documentation of angel_jael 1.0.0-alpha+1 Download angel_jael 1.0.0-alpha+1 archive
1.0.0-alpha Oct 1, 2017 Go to the documentation of angel_jael 1.0.0-alpha Download angel_jael 1.0.0-alpha archive
Popularity:
Describes how popular the package is relative to other packages. [more]
65
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
60
Overall:
Weighted score of the above. [more]
45
Learn more about scoring.

We analyzed this package on Oct 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status tool failures using:

  • Dart: 2.0.0
  • pana: 0.12.4

Platforms

Detected platforms: unsure

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Analysis issues and suggestions

Fix dependencies in pubspec.yaml.

Running pub upgrade failed with the following output:

ERR: The current Dart SDK version is 2.0.0.
 
 Because angel_jael depends on symbol_table <2.0.0 which requires SDK version >=1.19.0 <2.0.0, version solving failed.

Maintenance issues and suggestions

Fix platform conflicts. (-20 points)

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Dependencies

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