Skip to main content

Release 3.9 Support for Custom Elements

· One min read
Miguel Gamboa
HtmlFlow Author

A new custom element feature allows defining HtmlFlow views, as shown in the listing at the end of this post. This feature applies to both static and dynamic views.

You can find this sample in the unit tests at htmlflow.test.views.HtmlCustomElements.

Invoking .custom("alert-info") returns an instance of the new CustomElement class, which inherits from the existing Div class. As a result, the returned instance has most HTML features available.

Example usage:

CustomElement Example
StaticHtml
.view()
.html()
.head()
.script()
.attrSrc("alert.js")
.attrDefer(true)
.__()
.__()
.body()
.div()
.attrClass("container")
.p().text("Testing custom elements!").__()
.custom("alert-info")
.addAttr("title", "Information")
.addAttr("message", "This is a message for a custom element")
.addAttr("kind", "success")
.ul()
.li().text("For any reason we could even include other elements.").__()
.__()
.__()
.__()
.__()
.__();