Publish html_builder

This commit is contained in:
thomashii 2021-05-15 19:47:48 +08:00
parent 7a4d31ad7d
commit 4603bfcc69
5 changed files with 27 additions and 22 deletions

View file

@ -1,6 +1,9 @@
# html_builder
[![Pub](https://img.shields.io/pub/v/html_builder.svg)](https://pub.dartlang.org/packages/html_builder)
[![build status](https://travis-ci.org/thosakwe/html_builder.svg)](https://travis-ci.org/thosakwe/html_builder)
# angel3_html_builder
[![version](https://img.shields.io/badge/pub-v2.0.0-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)
[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/angel3/packages/html_builder/LICENSE)
Build HTML AST's and render them to HTML.
@ -11,14 +14,14 @@ In your `pubspec.yaml`:
```yaml
dependencies:
html_builder: ^1.0.0
angel3_html_builder: ^2.0.0
```
# Usage
```dart
import 'package:html_builder/html_builder.dart';
import 'package:angel3_html_builder/angel3_html_builder.dart';
main() {
void main() {
// Akin to React.createElement(...);
var $el = h('my-element', p: {}, c: []);
@ -64,9 +67,9 @@ i // Null attributes do not appear.
Standard HTML5 elements:
```dart
import 'package:html_builder/elements.dart';
import 'package:angel3_html_builder/elements.dart';
main() {
void main() {
var $dom = html(lang: 'en', c: [
head(c: [
title(c: [text('Hello, world!')])
@ -81,16 +84,16 @@ main() {
Rendering to HTML:
```dart
String html = new StringRenderer().render($dom);
String html = StringRenderer().render($dom);
```
Example with the [Angel](https://github.com/angel-dart/angel) server-side framework,
which has [dedicated html_builder support](https://github.com/angel-dart/html):
Example with the [Angel](https://github.com/dukefirehawk/angel/tree/angel3) server-side framework,
which has [dedicated html_builder support](https://github.com/dukefirehawk/angel/tree/html):
```dart
import 'dart:io';
import 'package:angel_framework/angel_framework.dart';
import 'package:html_builder/elements.dart';
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_html_builder/elements.dart';
configureViews(Angel app) async {
app.get('/foo/:id', (req, res) async {

View file

@ -1,8 +1,8 @@
/// Helper functions to build common HTML5 elements.
library html_builder.elements;
library angel3_html_builder.elements;
import 'html_builder.dart';
export 'html_builder.dart';
import 'angel3_html_builder.dart';
export 'angel3_html_builder.dart';
Map<String, dynamic> _apply(Iterable<Map<String, dynamic>> props,
[Map<String, dynamic>? attrs]) {

View file

@ -1,9 +1,11 @@
name: html_builder
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.0
homepage: https://github.com/thosakwe/html_builder
homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/html_builder
environment:
sdk: '>=2.12.0 <3.0.0'
dependencies:
collection: ^1.15.0
dev_dependencies:
html: ^0.15.0
test: ^1.17.3
test: ^1.17.4

View file

@ -1,9 +1,9 @@
import 'package:html/parser.dart' as html5;
import 'package:html_builder/elements.dart';
import 'package:html_builder/html_builder.dart';
import 'package:angel3_html_builder/elements.dart';
import 'package:angel3_html_builder/angel3_html_builder.dart';
import 'package:test/test.dart';
main() {
void main() {
test('pretty', () {
var $dom = html(
lang: 'en',