Move to precompiled handlebars templates.

In Nextcloud 15 the default Content Security Policy disallows unsafe
eval expressions, so Handlebars templates can no longer be compiled at
runtime.

Fix issue #18
This commit is contained in:
Matias De lellis
2019-02-12 12:29:11 -03:00
parent d1d1f1a2f6
commit 6bac24030d
10 changed files with 105 additions and 97 deletions

View File

@@ -290,10 +290,12 @@ View.prototype = {
return digits[1] + '#' + rgb.toString(16).toUpperCase();
},
renderContent: function () {
var source = $('#content-tpl').html();
var template = Handlebars.compile(source);
var html = template({notes: this._notes.getAll()});
var html = Handlebars.templates['notes']({
notes: this._notes.getAll(),
cancelTxt: t('quicknotes', 'Cancel'),
saveTxt: t('quicknotes', 'Save'),
emptyTxt: t('quicknotes', 'Nothing here. Take your quick notes.'),
});
$('#div-content').html(html);
// Init masonty grid to notes.
@@ -510,9 +512,14 @@ View.prototype = {
});
},
renderNavigation: function () {
var source = $('#navigation-tpl').html();
var template = Handlebars.compile(source);
var html = template({colors: this._notes.getColors(), notes: this._notes.getAll()});
var html = Handlebars.templates['navigation']({
colors: this._notes.getColors(),
notes: this._notes.getAll(),
newNoteTxt: t('quicknotes', 'New note'),
allNotesTxt: t('quicknotes', 'All notes'),
colorsTxt: t('quicknotes', 'Colors'),
notesTxt: t('quicknotes', 'Notes'),
});
$('#app-navigation ul').html(html);