Book Image

DART Essentials

Book Image

DART Essentials

Overview of this book

Table of Contents (16 chapters)
Dart Essentials
About the Author
About the Reviewers

Basic HTML Import

Time to see an HTML Import in action! Let's say we want to reuse this little greeting among multiple pages:

<!-- web/greeting.html -->
  <h1>Hello, imported world!</h1>

Now, insert it, for example, at the end of the body on this page (the following code). Note that CORS rules apply to imported HTML documents just as we saw in Chapter 3, The Power of HTML5 with Dart:

<!-- web/index.html -->
    <!-- Polyfill for browsers not supporting Web Components. -->
    <script src="packages/web_components/webcomponents.js">

    <link id="linkedCont" rel="import" href="greeting.html">

    <script type="application/dart" src="main.dart"></script>
    <script src="packages/browser/dart.js"></script>
    <!-- Insert greeting here. -->

This HTML just loads our greeting into a separate...