title: knockout 'if' inside an element
body: <p>I have a list of items and every item has a type. I need to show all the items but every type has its own "configuration" (binding, class, etc.). My code looks like that: </p>
  
  <pre><code>        &lt;!-- ko foreach: items --&gt;
                  &lt;!-- ko if: itemType == 'type1' --&gt;
                      &lt;div data-bind="value: $parent[itemName]"&gt;&lt;/div&gt;
                  &lt;!-- /ko --&gt;
                  &lt;!-- ko if: itemType == 'type2' --&gt;
                      &lt;div data-bind="value: $parent[itemName], bindingFunc1: foo"&gt;&lt;/div&gt;
                  &lt;!-- /ko --&gt;
                  &lt;!-- ko if: itemType == 'type3' --&gt;
                      &lt;div data-bind="value: $parent[itemName], bindingFunc2: bar"&gt;&lt;/div&gt;
                  &lt;!-- /ko --&gt;
                  &lt;!-- ko if: itemType == 'type4' --&gt;
                      &lt;div data-bind="value: $parent[itemName], bindingFunc1: foo, bindingFunc2: bar"&gt;&lt;/div&gt;
                  &lt;!-- /ko --&gt;
          &lt;!-- /ko --&gt;
  </code></pre>
  
  <p>You can see that <strong>all</strong> of the items has <code>value: $parent[itemName]</code> and I just duplicated it. </p>
  
  <p>In my original code - the duplicated code is much much longer and every time I want to change something I need to change it in  all the types.</p>
  
  <p>Is there any way to combine all the lines to one line and insert an "<code>if (type == ...)</code>" inside the <code>div</code> to add more bindings according the type?</p>