angel_jael 1.0.2

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

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.2 #

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

1.0.1 #

  • Use Renderer.errorDocument.

example/main.dart

import 'dart:convert';
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()..lazyParseBodies = true;
  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 app.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.2

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
2.0.0 Nov 10, 2018 Go to the documentation of angel_jael 2.0.0 Download angel_jael 2.0.0 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]
79
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
35
Overall:
Weighted score of the above. [more]
47
Learn more about scoring.

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

  • Dart: 2.3.2
  • pana: 0.12.18

Platforms

Detected platforms:

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.3.2.
 
 Because angel_jael 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.

Support the latest stable Dart SDK in pubspec.yaml. (-20 points)

The SDK constraint in pubspec.yaml doesn't allow the latest stable Dart SDK release.

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

The package description is too short. (-15 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

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