angel_jael 1.0.1

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

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.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.1"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages 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.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

Analysis

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

  • Dart: 2.0.0-dev.60.0
  • pana: 0.11.3

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
79 / 100
Health:
Code health derived from static analysis. [more]
98 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
89
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:angel_jael/angel_jael.dart.

Suggestions

  • The description is too short.

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

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 hint.

    Strong-mode analysis of lib/angel_jael.dart gave the following hint:

    line: 1 col: 8
    Unused import: 'dart:convert'.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <=2.0.0
angel_framework ^1.0.0-dev 1.1.4+3
code_buffer ^1.0.0 1.0.0
file ^2.0.0 2.3.7 5.0.1
jael ^1.0.0-alpha 1.0.4
jael_preprocessor ^1.0.0-alpha 1.0.0+1
symbol_table ^1.0.0 1.0.4
Transitive dependencies
angel_http_exception 1.0.0
angel_model 1.0.0
angel_route 2.0.6
async 2.0.7
body_parser 1.1.0
charcode 1.1.1
collection 1.14.10
combinator 1.0.0
container 0.1.2
dart2_constant 1.0.1+dart2
http_parser 3.1.2
http_server 0.9.7
intl 0.15.6
json_god 2.0.0-beta+1
logging 0.11.3+1
matcher 0.12.2+1
merge_map 1.0.0
meta 1.1.5
mime 0.9.6+1
path 1.6.0
pool 1.3.5
quiver_hashcode 1.0.0
random_string 0.0.1
source_span 1.4.0
stack_trace 1.9.2
string_scanner 1.0.2
tuple 1.0.1
typed_data 1.1.5
Dev dependencies
angel_test ^1.1.0-alpha
test ^0.12.0