this works for me.
var templ = Hogan.compile([
'<p class="repo-language">{{Barcode}}</p>',
'<p class="repo-name">{{sellPrice}}</p>',
'<p class="repo-description">{{description}}</p>'
].join(''));
$('#ItemLookup2').typeahead(null, {
displayKey: 'description',
source: values.ttAdapter(),
templates: {
suggestion: function (data) { return templ.render(data); }
}
});
check the source code how typeahead 10 call the template function. I just take the getFooterHtml snippet, getSuggestionsHtml works almost the same, but pass the different data and do some extra jobs.
function getFooterHtml() {
return that.templates.footer({
query: query,
isEmpty: !hasSuggestions
});
}
we should call render function explicitly to render for Hogan/Mustache.
Hogan.compile('sample {{data}}').render({"data": 'hey'});
but, Handlebars can works like this.
Handlebars.compile('sample {{data}}')({"data": 'hey'});
so, snippet 1 of questions by Handlerbars can works, but Hogan/Mustache should do some wrapper jobs.