Tech's HTML Bindings (Dart)
Very opinionated HTML bindings, for personal use in generating websites.
Features
Write HTML in Dart, in a kind of Flutter-like style and export it to files.
Very opinionated, so if you don't like it, use something else.
Maybe look into Jaspr. I've heard it's good.
Getting started
Add the package to your pubspec.yaml:
techs_html_bindings:
git:
url: https://github.com/TechnicJelle/techs_html_bindings.git
ref: main
You can use dart pub upgrade to update the package.
I might upload it on pub.dev later, once it's more complete and tested.
Usage
Short example:
final String html = HTML(
lang: "en",
head: Head(title: "Hello bindings!"),
body: Body(
header: Header(children: []),
main: Main(
children: [
...markdown(File("README.md").readAsStringSync()),
],
),
footer: Footer(children: []),
),
).build();
A more complete example can be found in the example directory.
The API Documentation can be found here.
A full usage demonstration can be seen on my portfolio website: github.com/TechnicJelle/TechnicJelle
A few notes
Strings are not escaped/sanitized automatically, so be mindful of XSS vulnerabilities.
(This may change in the future.)
(Image alt text is escaped automatically, though.)
You can use the .escape() extension method on Strings to manually escape things.
Additional information
Feel free to make feature requests and PRs on GitHub.
But do not request anything related to JavaScript, because that is explicitly a non-goal for this library.