Towards unopinionated Web templates
In this article, Miguel Gamboa et al. argue against the use of an external DSL
to implement HTML templates, such as using JSP, handlebars, Thymeleaf, Vue, or
others, that introduce new dialects such as th:each
, th:with
, v-for
,
v-if
, v-bind
, etc… On the other hand, an internal DSL like React JSX,
KotlinX.html, or HtmlFlow, let you fluently interleave constructs from the host
language (i.e. JavaScript, Kotlin, or Java, respectively) with the use of HTML.
Providing templating features through specific dialects incur the following drawbacks:
- weak or absent compile-time validation.
- idiomatic mix between HTML, template dialects and the host programming language.
- restricted suite of control flow features leveraged by template dialects.
- opinionated templating idioms.
- lack of asynchronous rendering support, according to asynchronous view models.
This work shows how an internal domain-specific language (DSL) for HTML (such as HtmlFlow, Kotlinx.html, or React JSX) can suppress the aforementioned limitations. To that end, this work uses the Spring Framework and the well-known sample application PetClinic to show how an internal DSL for HTML provides unopinionated web templates with boundless resolving features only ruled by the host programming language (such as Java, Kotlin, or JavaScript).