Different templating approaches

Knockout.js provides you with great opportunities to write reusable code. Another important task is writing reusable markup. This task can be solved with the help of named templates. It is a very convenient way to create a flexible view. We already discussed one template approach with the control flow bindings (foreach, if, and with). In this section, we will discuss another approach: the string-based templates. They help you connect Knockout.js with third-party templates' engines. The following parameters can be useful in such a case:

  • name: This is the name of the defined template
  • data: This is a model for the template
  • if: This is a condition under which the template will be rendered
  • foreach: This is a model for the ...

Get Getting Started with Knockout.js for .NET Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.