Created
June 8, 2017 13:40
-
-
Save emerson-pereira/33e905d2b54c6dced3b9c77ea8679fed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Template (.hbs) | |
var template = (function () { | |
var template = null; | |
$.ajax({ | |
type: 'GET', | |
dataType: 'html', | |
async: false, | |
url: 'templates/template.hbs', | |
success: function(res) { | |
template = res; | |
console.log('***** HTML template retrieved with success *****'); | |
} | |
}); | |
return template; | |
})(); | |
// Data (.json) | |
var ctx = (function () { | |
var data = null; | |
$.ajax({ | |
type: 'GET', | |
dataType: 'json', | |
async: false, | |
url: 'data.json', | |
success: function(res) { | |
data = res; | |
console.log('***** data.json retrieved with success *****'); | |
} | |
}); | |
return data; | |
})(); | |
var compiledTemplate = Handlebars.compile(template); | |
var finalMarkup = compiledTemplate(ctx); | |
$('#main-holder').html(finalMarkup); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment