Publish html_builder 2.0.1
This commit is contained in:
parent
37c586a7e5
commit
61bae79233
9 changed files with 529 additions and 516 deletions
|
@ -1,3 +1,6 @@
|
|||
# 2.0.1
|
||||
* Added pedantic dart rules
|
||||
|
||||
# 2.0.0
|
||||
* Migrated to work with Dart SDK 2.12.x NNBD
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# angel3_html_builder
|
||||
[![version](https://img.shields.io/badge/pub-v2.0.0-brightgreen)](https://pub.dartlang.org/packages/angel3_html_builder)
|
||||
[![version](https://img.shields.io/badge/pub-v2.0.1-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)
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
include: package:pedantic/analysis_options.yaml
|
||||
|
||||
analyzer:
|
||||
strong-mode:
|
||||
implicit-casts: false
|
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,7 @@ import 'node_builder.dart';
|
|||
|
||||
/// Returns a function that rebuilds an arbitrary [Node] by applying the [transform] to it.
|
||||
Node Function(Node) rebuild(NodeBuilder Function(NodeBuilder) transform,
|
||||
{bool selfClosing: false}) {
|
||||
{bool selfClosing = false}) {
|
||||
return (node) =>
|
||||
transform(NodeBuilder.from(node)).build(selfClosing: selfClosing);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class Node {
|
|||
|
||||
Node._selfClosing(this.tagName,
|
||||
[Map<String, dynamic> attributes = const {}]) {
|
||||
this..attributes.addAll(attributes);
|
||||
this.attributes.addAll(attributes);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -35,7 +35,10 @@ class Node {
|
|||
|
||||
/// Represents a self-closing tag, i.e. `<br>`.
|
||||
class SelfClosingNode extends Node {
|
||||
@override
|
||||
final String tagName;
|
||||
|
||||
@override
|
||||
final Map<String, dynamic> attributes = {};
|
||||
|
||||
@override
|
||||
|
|
|
@ -8,7 +8,7 @@ class NodeBuilder {
|
|||
Node? _existing;
|
||||
|
||||
NodeBuilder(this.tagName,
|
||||
{this.attributes: const {}, this.children: const []});
|
||||
{this.attributes = const {}, this.children = const []});
|
||||
|
||||
/// Creates a [NodeBuilder] that just spits out an already-existing [Node].
|
||||
factory NodeBuilder.existing(Node existingNode) =>
|
||||
|
@ -19,7 +19,7 @@ class NodeBuilder {
|
|||
children: List<Node>.from(node.children));
|
||||
|
||||
/// Builds the node.
|
||||
Node build({bool selfClosing: false}) =>
|
||||
Node build({bool selfClosing = false}) =>
|
||||
_existing ??
|
||||
(selfClosing
|
||||
? SelfClosingNode(tagName, attributes)
|
||||
|
@ -85,9 +85,11 @@ class NodeBuilder {
|
|||
var clazz = attributes['class'];
|
||||
var classes = <String>[];
|
||||
|
||||
if (clazz is String)
|
||||
if (clazz is String) {
|
||||
classes.addAll(clazz.split(' '));
|
||||
else if (clazz is Iterable) classes.addAll(clazz.map((s) => s.toString()));
|
||||
} else if (clazz is Iterable) {
|
||||
classes.addAll(clazz.map((s) => s.toString()));
|
||||
}
|
||||
|
||||
return setClasses(f(classes));
|
||||
}
|
||||
|
|
|
@ -14,10 +14,10 @@ abstract class StringRenderer implements Renderer<String> {
|
|||
/// If [pretty] is `true` (default), then [whitespace] (default: `' '`) will be inserted between nodes.
|
||||
/// You can also provide a [doctype] (default: `html`).
|
||||
factory StringRenderer(
|
||||
{bool html5: true,
|
||||
bool pretty: true,
|
||||
String doctype: 'html',
|
||||
String whitespace: ' '}) =>
|
||||
{bool html5 = true,
|
||||
bool pretty = true,
|
||||
String doctype = 'html',
|
||||
String whitespace = ' '}) =>
|
||||
pretty == true
|
||||
? _PrettyStringRendererImpl(
|
||||
html5: html5 != false, doctype: doctype, whitespace: whitespace)
|
||||
|
@ -81,7 +81,9 @@ class _PrettyStringRendererImpl implements StringRenderer {
|
|||
_PrettyStringRendererImpl({this.html5, this.whitespace, this.doctype});
|
||||
|
||||
void _applyTabs(int tabs, StringBuffer buf) {
|
||||
for (int i = 0; i < tabs; i++) buf.write(whitespace ?? ' ');
|
||||
for (var i = 0; i < tabs; i++) {
|
||||
buf.write(whitespace ?? ' ');
|
||||
}
|
||||
}
|
||||
|
||||
void _renderInto(int tabs, Node node, StringBuffer buf) {
|
||||
|
|
|
@ -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.0
|
||||
version: 2.0.1
|
||||
homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/html_builder
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
|
@ -9,3 +9,4 @@ dependencies:
|
|||
dev_dependencies:
|
||||
html: ^0.15.0
|
||||
test: ^1.17.4
|
||||
pedantic: ^1.11.0
|
Loading…
Reference in a new issue