html library

Typed, escaped HTML for Daravel responses (Laravel's Blade, as Dart functions). A separate import, because names such as a, p and text would clash with ordinary variables:

import 'package:daravel/html.dart';

Classes

Element
An element with attributes and children.
Fragment
Several nodes without a wrapping element.
HtmlDocument
A whole page: <!doctype html>, <head> with title, charset and viewport, and body.
HtmlNode
A typed HTML tree: text and attributes are escaped, raw markup has to be asked for (raw), and a node returned from a handler is sent as HTML.
RawHtml
Markup written as is (Blade's {!! $value !!}): only for trusted HTML.
TextNode
Text, escaped (Blade's {{ $value }}).

Functions

a(List<Object?> children, {required String href, String? classes, Map<String, Object?> attributes = const {}}) → Element
article(List<Object?> children, {String? id, String? classes, Map<String, Object?> attributes = const {}}) → Element
br() → Element
button(List<Object?> children, {String type = 'button', String? classes, Map<String, Object?> attributes = const {}}) → Element
code(List<Object?> children, {String? classes, Map<String, Object?> attributes = const {}}) → Element
div(List<Object?> children, {String? id, String? classes, Map<String, Object?> attributes = const {}}) → Element
document(List<Object?> body, {String title = '', List<Object?> head = const [], String lang = 'en'}) → HtmlDocument
el(String tag, [List<Object?> children = const [], String? id, String? classes, Map<String, Object?> attributes = const {}]) → Element
Any element: el('details', [...], attributes: {'open': true}).
em(List<Object?> children, {String? classes, Map<String, Object?> attributes = const {}}) → Element
escapeHtml(String value) → String
Escapes & < > " ' for text and attribute values.
form(List<Object?> children, {required String action, String method = 'POST', String? classes, Map<String, Object?> attributes = const {}}) → Element
fragment(List<Object?> children) → Fragment
h1(List<Object?> children, {String? id, String? classes, Map<String, Object?> attributes = const {}}) → Element
h2(List<Object?> children, {String? id, String? classes, Map<String, Object?> attributes = const {}}) → Element
h3(List<Object?> children, {String? id, String? classes, Map<String, Object?> attributes = const {}}) → Element
hr() → Element
img({required String src, required String alt, String? classes, Map<String, Object?> attributes = const {}}) → Element
input({required String name, String type = 'text', Object? value, String? id, String? classes, Map<String, Object?> attributes = const {}}) → Element
label(List<Object?> children, {String? forId, String? classes, Map<String, Object?> attributes = const {}}) → Element
li(List<Object?> children, {String? classes, Map<String, Object?> attributes = const {}}) → Element
mainEl(List<Object?> children, {String? id, String? classes, Map<String, Object?> attributes = const {}}) → Element
<main> (main is the Dart entry point name).
meta({Map<String, Object?> attributes = const {}}) → Element
ol(List<Object?> children, {String? id, String? classes, Map<String, Object?> attributes = const {}}) → Element
p(List<Object?> children, {String? id, String? classes, Map<String, Object?> attributes = const {}}) → Element
pre(List<Object?> children, {String? classes, Map<String, Object?> attributes = const {}}) → Element
raw(String html) → RawHtml
Trusted markup, written as is.
section(List<Object?> children, {String? id, String? classes, Map<String, Object?> attributes = const {}}) → Element
span(List<Object?> children, {String? id, String? classes, Map<String, Object?> attributes = const {}}) → Element
strong(List<Object?> children, {String? classes, Map<String, Object?> attributes = const {}}) → Element
table(List<Object?> children, {String? id, String? classes, Map<String, Object?> attributes = const {}}) → Element
tbody(List<Object?> children) → Element
td(List<Object?> children, {String? classes, Map<String, Object?> attributes = const {}}) → Element
text(Object? value) → TextNode
Escaped text.
textarea({required String name, String value = '', String? id, String? classes, Map<String, Object?> attributes = const {}}) → Element
th(List<Object?> children, {String? classes, Map<String, Object?> attributes = const {}}) → Element
thead(List<Object?> children) → Element
tr(List<Object?> children, {String? classes, Map<String, Object?> attributes = const {}}) → Element
ul(List<Object?> children, {String? id, String? classes, Map<String, Object?> attributes = const {}}) → Element