Updated HTML_Builder

This commit is contained in:
thomashii 2021-06-22 17:35:08 +08:00
parent 546abbc49f
commit 75138eb416
4 changed files with 46 additions and 16 deletions

View file

@ -1,18 +1,31 @@
# 2.0.2
# Change Log
## 2.0.3
* Added example
* Updated README
## 2.0.2
* Run `dartfmt -w .`
# 2.0.1
## 2.0.1
* Added pedantic dart rules
# 2.0.0
## 2.0.0
* Migrated to work with Dart SDK 2.12.x NNBD
# 1.0.4
## 1.0.4
* Added `rebuild`, `rebuildRecursive`, and `NodeBuilder`.
# 1.0.3
## 1.0.3
* Dart 2 ready!
# 1.0.2
## 1.0.2
Changed `h` and the `Node` constructor to take `Iterable`s of children,
instead of just `List`s.

View file

@ -1,5 +1,6 @@
# angel3_html_builder
[![version](https://img.shields.io/badge/pub-v2.0.2-brightgreen)](https://pub.dartlang.org/packages/angel3_html_builder)
# Angel3 Html Builder
[![version](https://img.shields.io/badge/pub-v2.0.3-brightgreen)](https://pub.dartlang.org/packages/angel3_html_builder)
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
[![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion)
@ -9,7 +10,8 @@ Build HTML AST's and render them to HTML.
This can be used as an internal DSL, i.e. for a templating engine.
# Installation
## Installation
In your `pubspec.yaml`:
```yaml
@ -17,7 +19,8 @@ dependencies:
angel3_html_builder: ^2.0.0
```
# Usage
## Usage
```dart
import 'package:angel3_html_builder/angel3_html_builder.dart';
@ -25,13 +28,12 @@ void main() {
// Akin to React.createElement(...);
var $el = h('my-element', p: {}, c: []);
// Attributes can be plain Strings.
h('foo', p: {
'bar': 'baz'
});
i // Null attributes do not appear.
// Null attributes do not appear.
h('foo', p: {
'does-not-appear': null
});
@ -41,7 +43,7 @@ i // Null attributes do not appear.
'appears': true,
'does-not-appear': false
});
:
// Or, a String or Map.
h('foo', p: {
'style': 'background-color: white; color: red;'
@ -51,7 +53,7 @@ i // Null attributes do not appear.
'style': {
'background-color': 'white',
'color': 'red'
/ }
}
});
// Or, a String or Iterable.

View file

@ -0,0 +1,15 @@
import 'package:angel3_html_builder/elements.dart';
void main() {
var dom = html(lang: 'en', c: [
head(c: [
title(c: [text('Hello, world!')])
]),
body(c: [
h1(c: [text('Hello, world!')]),
p(c: [text('Ok')])
])
]);
print(dom);
}

View file

@ -1,6 +1,6 @@
name: angel3_html_builder
description: Build HTML AST's and render them to HTML. This can be used as an internal DSL, i.e. for a templating engine.
version: 2.0.2
version: 2.0.3
homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/html_builder
environment:
sdk: '>=2.12.0 <3.0.0'