In my multitenant app, I have many instances of the following:
<!-- ko if: tenantA() -->
<div>Tenant One snippet</div>
<!-- /ko -->
<!-- ko if: tenantB() -->
<div>Tenant Two snippet</div>
<!-- /ko -->
<!-- ko if: userTypeA() -->
<div>User type A snippet</div>
<!-- /ko -->
<!-- ko if: userTypeB() -->
<div>User type B snippet</div>
<!-- /ko -->
This is an oversimplified example but you get the picture - many components of a larger view are composed based on business logic from various data points.
The benefit of this is that I have one view and the solution footprint is more manageable, but it is a bit messy. What alternative patterns are there?
I was considering splitting anything and everything that is displayed on condition into an html template and rendering html based on logic in the js viewmodel, but this introduces more complexity into my viewmodels and muddles up my solution footprint (this is important to me for quick navigation during dev).
I am working with durandal and knockout but tagged Aurelia
because I will be migrating sometime and think this is more of a pattern question than a particular technology question.
HTML templates always tend to become messy and difficult to maintain once your app starts to grow big.
I would suggest you to break your HTML into multiple components there by It will be easier to maintain and most important you will end up reusing all these components.
one of the greatest example would be JSX which works best with React.js where in you can write HTML inside JS. so you can divide your app into maintainable components. give JSX a try it really makes your life lot easier as font-end developer.