O'Reilly logo

Getting Started with Knockout.js for .NET Developers by Andrey Akinshin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required