package polymer


Polymer.dart

Polymer.dart is a set of comprehensive UI and utility components for building web applications. With Polymer.dart's custom elements, templating, data binding, and other features, you can quickly build structured, encapsulated, client-side web apps.

Polymer.dart is a Dart port of Polymer created and maintained by the Dart team. The Dart team is collaborating with the Polymer team to ensure that polymer.dart elements and polyfills are fully compatible with Polymer.

Polymer.dart replaces Web UI, which has been deprecated.

Learn More

Try It Now

Add the polymer.dart package to your pubspec.yaml file:

dependencies:
  polymer: ">=0.16.0 <0.17.0"

Instead of using any, we recommend using version ranges to avoid getting your project broken on each release. Using a version range lets you upgrade your package at your own pace. You can find the latest version number at https://pub.dartlang.org/packages/polymer.

Building and Deploying

To build a deployable version of your app, add the polymer transformers to your pubspec.yaml file:

transformers:
- polymer

Then, run pub build. The polymer transformers assume all files under web are possible entry points, this can be adjusted with arguments in your pubspec.yaml file. For example, you can say only web/index.html is an entry point as follows:

transformers:
- polymer:
    entry_points: web/index.html

Here is a list of arguments used by the polymer transformers: * js: whether to load JS code directly. By default polymer converts your app's html file to load the compiled JS code directly. Setting this parameter to false will keep a dart script tag and the dart.js script tag on the page.

For example, this specification includes 2 entrypoints and chooses the CSP compliant JS file:

transformers:
- polymer:
    entry_points:
    - web/index.html
    - web/index2.html
    csp: true

Testing

Polymer elements can be tested using either the original unittest or new test packages. In both cases the easiest way to create a test is by using the default main from polymer/init.dart and then defining all your tests inside of a method marked with an @whenPolymerReady annotation.

import 'package:polymer/polymer.dart';
export 'package:polymer/init.dart';

@whenPolymerReady
void runTests() {
  // Define your tests here.
}

You will also need to define a custom html file for your test (see the README for the testing package you are using for more information on this).

Note: If you are using the new test package, it is important that you add the test transformer after the polymer transformer, so it should look roughly like this:

transformer:
- polymer:
    entry_points:
      - test/my_test.html
- test/pub_serve:
    $include: test/**_test{.*,}.dart

Contacting Us

Please file issues in our Issue Tracker or contact us on the Dart Web mailing list.

We also have a Dart Slack Channel for discussions about internals of the code, code reviews, etc.

Libraries

polymer

Custom HTML tags, data binding, and templates for building structured, encapsulated, client-side web apps.

polymer.auto_binding
polymer.builder

Common logic to make it easy to run the polymer linter and deploy tool.

polymer.default_build

Library that defines a main which calls build() from builder.dart. For polymer projects the build.dart file can simply export this to make the linter run on all of the entry points defined in your pubspec.yaml.

polymer.deploy

Note: If you already have a build.dart in your application, we recommend to use the package:polymer/builder.dart library instead. Temporary deploy command used to create a version of the app that can be compiled with dart2js and deployed. Following pub layout conventions, this script will treat any HTML file under a package 'web/' and 'test/' directories as entry points.

polymer.deserialize
polymer.html_element_names
polymer.init

Library that automatically initializes polymer elements without having to write a main for your application.

polymer.transformer

Transfomer used for pub-serve and pub-deploy.