angel_jael 1.0.0-alpha+2 copy "angel_jael: ^1.0.0-alpha+2" to clipboard
angel_jael: ^1.0.0-alpha+2 copied to clipboard

outdated

Angel support for the Jael templating engine.

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}');
}
0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

Angel support for the Jael templating engine.

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

angel_framework, code_buffer, file, jael, jael_preprocessor, symbol_table

More

Packages that depend on angel_jael