Skip to content

Instantly share code, notes, and snippets.

@kasperpeulen
Last active August 29, 2015 14:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kasperpeulen/536b021ac1cf397d4e6d to your computer and use it in GitHub Desktop.
Save kasperpeulen/536b021ac1cf397d4e6d to your computer and use it in GitHub Desktop.
How to dynamically load HTML and insert into a webpage with Dart
<!doctype html>
<html>
<head>
</head>
<body>
<div></div>
<script type="application/dart" src="main.dart"></script>
</body>
</html>
import 'dart:html';
DivElement div = querySelector('div');
main() async {
String template = await HttpRequest.getString("template.html");
div.setInnerHtml(template, treeSanitizer: NodeTreeSanitizer.trusted);
}
name: dart.html_NodeTreeSanitizer.trusted
main_library: dart.html
main_elements: NodeTreeSanitizer.trusted
description: |
How to dynamically load HTML and insert into a webpage with Dart
homepage: https://gist.github.com/kasperpeulen/536b021ac1cf397d4e6d
environment:
sdk: '>=1.12.0-dev.4.0 <2.0.0'
<h1>Hello world.</h1>
Check my bird... <em>it flies</em> !
<img src="https://www.dartlang.org/logos/dart-bird.svg">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment