I am trying to use handlebars.js to create and then inject html into a webpage. I'm testing it out using json written inside of the script before attempting to integrate the server. I have checked the json in a validator and it is all good, but I still get an error from the handlebars template claiming "not well-formed".
I read a few other people who were having issues with Cross Origin Requests, but I use Firefox which is the solution they suggest (Q: not well-formed Source File in mozilla firefox)
Could it be something with my handlebars file?
Here is my js code:
var html;
var data= { "array":[
{"firstname":"Joe","lastname":"Shmoe"},
{"firstname":"John","lastname":"Connor"}
]};
console.log(data);
$.get("templates/coach-list-template.hbs",function(data){
var template= Handlebars.compile(data);
var handlebarshtml=template(data);
console.log(handlebarshtml);
console.log("Data: "+data);
},"html");
And here is the handlebars code:
{{#each array}}
<div class="row">
<div class="col-100"> {{firstname}} {{lastname}}</div>
</div>
{{/each}}