function renderContractDriveTPL(filename, data, selector) { data.translate = translate; var path = '/assets/apps/ContractDrive/templates/'; var content = getTemplate(path + filename, data); if (typeof(selector) == 'undefined') { return content; } else { $(selector).html(content); } } function getTemplate(file, data) { var source = getSource(file); var template = Handlebars.compile(source); return template(data); } function getSource(file) { var source = null; $.ajax({ async: false, dataType: 'html', type: 'GET', url: file + '?' + Date.now(), success: function(data) { source = data; } }); return source; } function view(template_id, data) { // console.log(template_id); // console.log(data); var source = document.getElementById(template_id).innerHTML; var template = Handlebars.compile(source); return template(data); } function helperSelect(name, items, selected, options) { // If the selected value is an array, then convert the // select to a multiple select if (selected instanceof Array) { options.hash.multiple = 'multiple'; } // Generate the list of options var optionsHtml = ''; for (var i = 0, j = items.length; i < j; i++) { //