I have a html template and a json object which I am trying to bind to this template.
var template="<li class=\"ui-menu-item\">\r\n\t<div class=\"container\">\r\n\t\t
<div class=\"content\">\r\n\t\t\t<img src=\"\" alt=\"\" data-field=\"field2\">
\r\n\t\t</div>\r\n\t\t<p data-field=\"field1\"></p>\r\n\t\t<p>
<span data-field=\"field3\"></span><span data-field=\"field4\"></span>
</p>\r\n\t</div>\r\n</li>";
var source=[{
field1: "value1",
field2: "value2",
field3: "value3",
field4: "value4",
extrafieldn: "valuen"
}];
I don't want to use a binding library. Is there some way to iterate over the data-field in the template and read it from the source to finally fill the relevant field in the template.
For example, find that field2 is required from the data-field for image, read its value from source and insert this value in the src.