angel_jael 1.0.0-alpha+1

  • README.md
  • Example
  • Installing
  • Versions
  • 38

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.

example/main.dart

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();
    var msg = body['message'] ?? '<unknown>';
    return await res
        .render('index', {'title': 'Form Submission', 'message': 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.0-alpha+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: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]
77
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
38
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Maintenance issues and suggestions

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

Dependencies were not resolved.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0