angel_jael 2.0.0
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
.
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';
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
81
|
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]
|
41
|
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://dart.dev/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 | >=2.0.0-dev <=3.0.0 |