From c4b0fa0b4f99f3fd4632b904d3b71c8e21ec0896 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Wed, 27 Jun 2018 19:57:53 -0400 Subject: [PATCH] If node now only renders if `true` --- angel_jael/example/main.dart | 7 ++++--- angel_jael/lib/angel_jael.dart | 1 - jael/lib/src/renderer.dart | 11 ++++++++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/angel_jael/example/main.dart b/angel_jael/example/main.dart index b0182f6c..e0048355 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_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 http = new AngelHttp(app); var fileSystem = const LocalFileSystem(); await app.configure( @@ -22,7 +23,7 @@ main() async { return await res.render('index', { 'title': 'Form Submission', 'message': msg, - 'json_message': JSON.encode(msg), + 'json_message': json.encode(msg), }); }); @@ -35,6 +36,6 @@ main() async { if (rec.stackTrace != null) print(rec.stackTrace); }); - var server = await app.startServer(null, 3000); + var server = await http.startServer(null, 3000); print('Listening at http://${server.address.address}:${server.port}'); } diff --git a/angel_jael/lib/angel_jael.dart b/angel_jael/lib/angel_jael.dart index dc7d9c8d..61de117f 100644 --- a/angel_jael/lib/angel_jael.dart +++ b/angel_jael/lib/angel_jael.dart @@ -1,4 +1,3 @@ -import 'dart:convert'; import 'package:angel_framework/angel_framework.dart'; import 'package:code_buffer/code_buffer.dart'; import 'package:file/file.dart'; diff --git a/jael/lib/src/renderer.dart b/jael/lib/src/renderer.dart index 30f6be84..a563fa37 100644 --- a/jael/lib/src/renderer.dart +++ b/jael/lib/src/renderer.dart @@ -203,7 +203,7 @@ class Renderer { Element element, CodeBuffer buffer, SymbolTable scope, bool html5) { var attribute = element.attributes.singleWhere((a) => a.name == 'if'); - if (!attribute.value.compute(scope)) return; + if (attribute.value.compute(scope) != true) return; var otherAttributes = element.attributes.where((a) => a.name != 'if'); Element strippedElement; @@ -301,4 +301,13 @@ class Renderer { renderElement(child, buffer, scope, html5); } } + + void registerCustomElement( + Element element, CodeBuffer buffer, SymbolTable scope, bool html5) { + var name = element.getAttribute('name')?.value?.compute(scope)?.toString(); + + if (name) { + + } + } }