diff --git a/angel_jael/CHANGELOG.md b/angel_jael/CHANGELOG.md index 80138a1a..695b9be9 100644 --- a/angel_jael/CHANGELOG.md +++ b/angel_jael/CHANGELOG.md @@ -1,3 +1,7 @@ +# 2.0.0 +* Angel 2 and Dart 2 updates. +* Default to `.jael` instead of `.jl`. + # 1.0.3 * Update for annoying map casting bug. diff --git a/angel_jael/README.md b/angel_jael/README.md index a5f544f4..0ac62b18 100644 --- a/angel_jael/README.md +++ b/angel_jael/README.md @@ -62,7 +62,7 @@ main() async { jael(fileSystem.directory('views')), ); - // Render the contents of views/index.jl + // Render the contents of views/index.jael app.get('/', (res) => res.render('index', {'title': 'ESKETTIT'})); app.use(() => throw new AngelHttpException.notFound()); diff --git a/angel_jael/example/main.dart b/angel_jael/example/main.dart index e0048355..ee902dc1 100644 --- a/angel_jael/example/main.dart +++ b/angel_jael/example/main.dart @@ -1,11 +1,12 @@ +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:dart2_constant/convert.dart'; import 'package:file/local.dart'; import 'package:logging/logging.dart'; main() async { - var app = new Angel()..lazyParseBodies = true; + var app = new Angel(); var http = new AngelHttp(app); var fileSystem = const LocalFileSystem(); @@ -13,11 +14,13 @@ main() async { jael(fileSystem.directory('views')), ); - app.get('/', - (res) => res.render('index', {'title': 'Sample App', 'message': null})); + app.get( + '/', + (req, res) => + res.render('index', {'title': 'Sample App', 'message': null})); app.post('/', (RequestContext req, res) async { - var body = await req.lazyBody(); + var body = await req.parseBody(); print('Body: $body'); var msg = body['message'] ?? ''; return await res.render('index', { @@ -27,7 +30,7 @@ main() async { }); }); - app.use(() => throw new AngelHttpException.notFound()); + app.fallback((req, res) => throw new AngelHttpException.notFound()); app.logger = new Logger('angel') ..onRecord.listen((rec) { @@ -36,6 +39,6 @@ main() async { if (rec.stackTrace != null) print(rec.stackTrace); }); - var server = await http.startServer(null, 3000); + var server = await http.startServer('127.0.0.1', 3000); print('Listening at http://${server.address.address}:${server.port}'); } diff --git a/angel_jael/example/views/index.jl b/angel_jael/example/views/index.jael similarity index 100% rename from angel_jael/example/views/index.jl rename to angel_jael/example/views/index.jael diff --git a/angel_jael/example/views/layout.jl b/angel_jael/example/views/layout.jael similarity index 100% rename from angel_jael/example/views/layout.jl rename to angel_jael/example/views/layout.jael diff --git a/angel_jael/lib/angel_jael.dart b/angel_jael/lib/angel_jael.dart index e7c6f4b3..0c9946d4 100644 --- a/angel_jael/lib/angel_jael.dart +++ b/angel_jael/lib/angel_jael.dart @@ -19,7 +19,7 @@ AngelConfigurer jael(Directory viewsDirectory, bool asDSX: false, CodeBuffer createBuffer()}) { var cache = {}; - fileExtension ??= '.jl'; + fileExtension ??= '.jael'; createBuffer ??= () => new CodeBuffer(); return (Angel app) async { diff --git a/angel_jael/pubspec.yaml b/angel_jael/pubspec.yaml index adbc28d2..012cb7b6 100644 --- a/angel_jael/pubspec.yaml +++ b/angel_jael/pubspec.yaml @@ -1,6 +1,6 @@ name: angel_jael version: 2.0.0 -description: Angel support for the Jael templating engine. +description: Angel support for the Jael templating engine, similar to Blade or Liquid. author: Tobe O homepage: https://github.com/angel-dart/jael/tree/master/jael environment: @@ -9,9 +9,10 @@ dependencies: angel_framework: ^2.0.0-alpha code_buffer: ^1.0.0 file: ^5.0.0 - jael: ^1.0.0-alpha - jael_preprocessor: ^1.0.0-alpha + jael: ^2.0.0 + jael_preprocessor: ^2.0.0 symbol_table: ^2.0.0 dev_dependencies: angel_test: ^2.0.0-alpha + html: test: ^1.0.0 diff --git a/angel_jael/test/all_test.dart b/angel_jael/test/all_test.dart index 2b239c76..3ddaa039 100644 --- a/angel_jael/test/all_test.dart +++ b/angel_jael/test/all_test.dart @@ -2,6 +2,7 @@ import 'package:angel_framework/angel_framework.dart'; import 'package:angel_jael/angel_jael.dart'; import 'package:angel_test/angel_test.dart'; import 'package:file/memory.dart'; +import 'package:html/parser.dart' as html; import 'package:logging/logging.dart'; import 'package:test/test.dart'; @@ -19,7 +20,7 @@ main() { var fileSystem = new MemoryFileSystem(); var viewsDirectory = fileSystem.directory('views')..createSync(); - viewsDirectory.childFile('layout.jl').writeAsStringSync(''' + viewsDirectory.childFile('layout.jael').writeAsStringSync(''' @@ -33,13 +34,14 @@ main() { '''); - viewsDirectory.childFile('github.jl').writeAsStringSync(''' - + viewsDirectory.childFile('github.jael').writeAsStringSync(''' + {{username}} '''); - app.get('/github/:username', (String username, ResponseContext res) { + app.get('/github/:username', (req, res) { + var username = req.params['username']; return res.render('github', {'username': username}); }); @@ -47,7 +49,7 @@ main() { jael(viewsDirectory), ); - app.use(() => throw new AngelHttpException.notFound()); + app.fallback((req, res) => throw new AngelHttpException.notFound()); app.logger = new Logger('angel') ..onRecord.listen((rec) { @@ -62,11 +64,10 @@ main() { test('can render', () async { var response = await client.get('/github/thosakwe'); print('Body:\n${response.body}'); - expect( - response, - hasBody(''' - + html.parse(response.body).outerHtml, + html + .parse(''' @@ -76,8 +77,8 @@ main() { <body> thosakwe </body> -</html> - ''' - .trim())); +</html>''' + .trim()) + .outerHtml); }); }