Avantages of HTML-only views compared to viewmodel-backed views

While surfing the Aurelia Discourse forums, I noticed that several posts ask how to apply specific (complex) logic with HTML-only views.

I understand the elegance of simple HTML-only views. But personally, I see no disadvantage in adding/using a viewmodel when logic gets more complex. Actually, I personally would prefer to use a viewmodel if implementing certain logic in an HTML-only view would result in more obscure HTML syntax and implementing it in a viewmodel would result in cleaner code.

Out of curiosity, I would like to learn why anybody would try to stick with HTML-only views, even when they have to use more complex logic. Do HTML-only views have certain technical advantages over a viewmodel-backed view, for example?

2 Likes

HTML-only views dont have technical advantages over traditional VM backed views.
obviously, anything that can be done in HTML-only, would be available in a HTML+VM pair - because it also contains the HTML part.

the reason to use HTML-only views, are simplicity and clean code in the cases you dont need a VM.
for some minor logics (including bindables) you can still use HTML-only.

but as soon as you need to inject services you have to use the VM approach.

you have gray area for views that have slightly complex logic that still can be expressed in HTML-only views.
in those cases I would suggest to move over to a HTML + VM pair.

4 Likes