http://jsfiddle.net/tQnVt/621/
This fiddle illustrates my problem.
Say I am binding a JSON onto view with the help of jsrender templates.
var vm = {
foo: {color: "red",otherObjectToMatch:"object"},
testData: [{color: "red"}, {color: "yellow"}, {color: "blue"}]
};
Object vm
has 2 properties-
1) a plain object
2) array of objects.
Template-
<script id="template" type="text/x-jsrender">
<p>
{{:foo.color}}
</p>
<ul>
{{for testData}}
<li>index: {{>color}}</li>
{{/for}}
</ul>
</script>
I want to match from plain object #1
by its property where if its property color matches with the property in loop then will apply some class.
I tried-
<p>
{{:foo.color}}
</p>
<ul>
{{for testData}}
{{if foo.color=={{>color}} }}
<li class='match'>index: {{>color}}</li>
{{else}}
<li>index: {{>color}}</li>
{{/if}}
{{/for}}
</ul>
This is a failed try. I can't find how to match with other objects in jsrender.