Objectos 0.5.0 released. Introduces Objectos HTML
Welcome to Objectos Weekly issue #017.
I have released Objectos 0.5.0! It introduces Objectos HTML, an open-source Java library for generating HTML using pure Java. Though it is publicly released it is not ready for public consumption yet. I will work on its public API during the 0.5.x release stream.
I initially planned to continue the discussion on the implementation of Objectos Code in this issue. But I failed to properly work on the article last Friday due to personal issues. So, in this issue, I will introduce Objectos HTML very briefly.
Let's begin.
Objectos HTML
The first thing to know is that this web page you are reading now was created using Objectos HTML. If you are reading this via the newsletter, the main HTML source code was also generated using Objectos HTML. The documentation of Objectos is also generated with Objectos HTML.
A "Hello, world" example would be the following:
import java.util.List;
import objectos.html.HtmlTemplate;
public class Example extends HtmlTemplate {
@Override
protected final void definition() {
doctype();
html(
lang("en"),
head(
meta(charset("utf-8")),
title("Objectos HTML example")
),
body(
h1("Objectos Libraries"),
ul(
f(this::items)
)
)
);
}
private void items() {
var names = List.of(
"Objectos HTML",
"Objectos Code",
"Objectos Lang",
"Objectos Util");
for (var name : names) {
li(name);
}
}
}
Which can generate a HTML file equivalent to:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Objectos HTML example</title>
</head>
<body>
<h1>Objectos Libraries</h1>
<ul>
<li>Objectos HTML</li>
<li>Objectos Code</li>
<li>Objectos Lang</li>
<li>Objectos Util</li>
</ul>
</body>
</html>
The actual output might be slightly different; the current default writer generates a minified HTML.
So the actual output would be:
<!doctype html><html lang="en"><head><meta charset="utf-8">
Generating the pretty-print output by default is one of the many things I will be working on the Objectos 0.5.x release stream.
Alpha quality
As mentioned before, Objectos HTML is alpha software:
-
it is not stable yet;
-
API might change substantially between minor/patch releases; and
-
documentation is currently non-existent.
Objectos Code
This release fixes some bugs in Objectos Code. Mostly related to the output format:
-
new lines emitted when they shouldn't have been; and
-
no new lines emitted when they should have.
Most of the work was done in the documentation. I started working on the documentation of field declarations. Be sure to check it out.
Until the next issue of Objectos Weekly
So that's it for today. I hope you enjoyed reading.
Please send me an e-mail if you have comments, questions or corrections regarding this post.