tags 0.0.2
tags: ^0.0.2 copied to clipboard
Build html elements by tag name.
Tags #
Build html elements by tag name in Dart.
Motivation #
This library is inspired by Bob's idea from the mailing list.
It can be difficult to discover all of the elements in dart:html. It can also
be tedious to construct them:
import 'dart:html';
var h = new HeadingElement.h1();
Tags lets you use the names you are already familiar with, to construct new elements in fewer keystrokes:
import 'package:tags/html.dart';
var h = h1();
Build Html #
Tags makes it easy to build up hierarchical html. When you call a builder
function (html tag name) you may pass a build() function as a parameter. This
build() function will be called by the builder function. Any builder
functions (tags) that you call from this function will be appended in order to
the parent element. Consider the following example:
document.body.append(
ul(() {
li()..text = 'Coffee';
li()..text = 'Tea';
li()..text = 'Milk';
}));
In the example above, we append three <li> elements to the <ul> element to
create an unordered list that we append to document.body. This is equivalent
to:
<body>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
</body>
Contribute #
Collaborate, send pull requests, and provide feedback please!
Tags uses the MIT license as described in the LICENSE file, and follows semantic versioning.