Search code examples
knockout.jsknockout-2.0single-page-applicationdurandalhottowel

Is Duranda's compose a good replacement over knockout templates


In the first 'Code Camper' course by John Papa, there was using knockout templates like{control}.tmpl.html format.

But in the next course 'Code Camper Jump Start', everywhere is using compose method by Durandal. Is compose method as a better solution for creating User Controls?

As Durandal's Api is more simple than ko templates, is there any advantage to use ko external template over Durandal's compose?

If so, what's the exact losses if I use compose method? Is it slower or something like that?


Solution

  • Compose works the same way as traditional knockout templates with a slight difference. Traditional knockout templates can handle templates defined within your html. Unless you use an external template engine. With Durandal's compose model, you have the flexibility of creating a brand new context or using the parent context itself. Also, it is a much cleaner way of composing your views. The same can be achieved with ko external template engine, but that would involve using three extra script libraries to achieve it (trafficcop, infuse and ko external templating engine). Bottom line, use Durandal's compose.