If node now only renders if true
This commit is contained in:
parent
5a7eccbcb8
commit
c4b0fa0b4f
3 changed files with 14 additions and 5 deletions
|
@ -1,11 +1,12 @@
|
||||||
import 'dart:convert';
|
|
||||||
import 'package:angel_framework/angel_framework.dart';
|
import 'package:angel_framework/angel_framework.dart';
|
||||||
import 'package:angel_jael/angel_jael.dart';
|
import 'package:angel_jael/angel_jael.dart';
|
||||||
|
import 'package:dart2_constant/convert.dart';
|
||||||
import 'package:file/local.dart';
|
import 'package:file/local.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
|
|
||||||
main() async {
|
main() async {
|
||||||
var app = new Angel()..lazyParseBodies = true;
|
var app = new Angel()..lazyParseBodies = true;
|
||||||
|
var http = new AngelHttp(app);
|
||||||
var fileSystem = const LocalFileSystem();
|
var fileSystem = const LocalFileSystem();
|
||||||
|
|
||||||
await app.configure(
|
await app.configure(
|
||||||
|
@ -22,7 +23,7 @@ main() async {
|
||||||
return await res.render('index', {
|
return await res.render('index', {
|
||||||
'title': 'Form Submission',
|
'title': 'Form Submission',
|
||||||
'message': msg,
|
'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);
|
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}');
|
print('Listening at http://${server.address.address}:${server.port}');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import 'dart:convert';
|
|
||||||
import 'package:angel_framework/angel_framework.dart';
|
import 'package:angel_framework/angel_framework.dart';
|
||||||
import 'package:code_buffer/code_buffer.dart';
|
import 'package:code_buffer/code_buffer.dart';
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
|
|
|
@ -203,7 +203,7 @@ class Renderer {
|
||||||
Element element, CodeBuffer buffer, SymbolTable scope, bool html5) {
|
Element element, CodeBuffer buffer, SymbolTable scope, bool html5) {
|
||||||
var attribute = element.attributes.singleWhere((a) => a.name == 'if');
|
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');
|
var otherAttributes = element.attributes.where((a) => a.name != 'if');
|
||||||
Element strippedElement;
|
Element strippedElement;
|
||||||
|
@ -301,4 +301,13 @@ class Renderer {
|
||||||
renderElement(child, buffer, scope, html5);
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue