angel_jael 2.0.0

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

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.jael
  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.

2.0.0

  • Angel 2 and Dart 2 updates.
  • Default to .jael instead of .jl.

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 'dart:convert';
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_framework/http.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 http = new AngelHttp(app);
  var fileSystem = const LocalFileSystem();

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

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

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

  app.fallback((req, res) => 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('127.0.0.1', 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: ^2.0.0

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]
71
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]
85
Learn more about scoring.

We analyzed this package on Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7

Platforms

Detected platforms: other

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <=3.0.0
angel_framework ^2.0.0-alpha 2.0.0-alpha.14
code_buffer ^1.0.0 1.0.1
file ^5.0.0 5.0.6
jael ^2.0.0 2.0.1+2
jael_preprocessor ^2.0.0 2.0.1
symbol_table ^2.0.0 2.0.0
Transitive dependencies
angel_container 1.0.0
angel_http_exception 1.0.0+3
angel_model 1.0.0+1
angel_route 3.0.0
body_parser 1.1.1
charcode 1.1.2
collection 1.14.11
combinator 1.0.0+3
convert 2.0.2
crypto 2.0.6
dart2_constant 1.0.2+dart2
http2 0.1.9
http_parser 3.1.3
http_server 0.9.8+1
intl 0.15.7
logging 0.11.3+2
matcher 0.12.4
merge_map 1.0.1
meta 1.1.6
mime 0.9.6+2
mock_request 1.0.4
path 1.6.2
quiver 2.0.1
source_span 1.4.1
stack_trace 1.9.3
string_scanner 1.0.4
tuple 1.0.2
typed_data 1.1.6
uuid 1.0.3
Dev dependencies
angel_test ^2.0.0-alpha
html any
test ^1.0.0