Reputation: 21
I would like to use Handlebars JS in my Fabricator JS project.
I had already developed the project with handlebars as a stand alone solution and finished it functionally.
When I install it in Fabricator I get a blank page and my handlebars {{}}
tags are empty. Does anyone know how to use these two plug-ins together?
HTML:
<div class="output-div"></div>
<script type="text/x-handlebars-template" id="my-template">
{{#header}}
<th scope="col" data-tablesaw-priority="persist">{{title}}</th>
<th scope="col" data-tablesaw-priority="2">{{type}}</th>
<th scope="col" data-tablesaw-priority="3">{{date}}</th>
<th scope="col" data-tablesaw-priority="4">{{dateExpired}}</th>
{{/header}}
</script>
json file:
{
"header": [
{
"title": "Titel",
"type": "Typ",
"date": "Erstellung",
"dateExpired": "Gueltig bis"
}
]
}
JS:
source = $('#my-template').html();
template = Handlebars.compile(source)(json_data);
$('.output-div').append(template);
the variable (json_data) is the ajax object with the json data inside. This example is functional without fabricator but inside fabricator no ouput is shown.
Fabricator: http://fbrctr.github.io/ Handlebars: http://handlebarsjs.com
Upvotes: 1
Views: 93