mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-24 01:10:31 +01:00
Use Benchpress (#5901)
* Use Benchpress * Use Benchpress.compileParse * Error for template load failure * Use benchpressjs package * Compile templates on demand * Fix user settings page * Fix admin search to exclude `.jst` files * Fix 500-embed So ajaxify can still show an error if the server goes down
This commit is contained in:
committed by
Barış Soner Uşaklı
parent
864321f727
commit
abffc29128
@@ -328,20 +328,10 @@ $(document).ready(function () {
|
||||
};
|
||||
|
||||
ajaxify.loadTemplate = function (template, callback) {
|
||||
if (templates.cache[template]) {
|
||||
callback(templates.cache[template]);
|
||||
} else {
|
||||
$.ajax({
|
||||
url: config.relative_path + '/assets/templates/' + template + '.tpl?' + config['cache-buster'],
|
||||
type: 'GET',
|
||||
success: function (data) {
|
||||
callback(data.toString());
|
||||
},
|
||||
error: function (error) {
|
||||
throw new Error('Unable to load template: ' + template + ' (' + error.statusText + ')');
|
||||
},
|
||||
});
|
||||
}
|
||||
require([config.relative_path + '/assets/templates/' + template + '.jst'], callback, function (err) {
|
||||
console.error('Unable to load template: ' + template);
|
||||
throw err;
|
||||
});
|
||||
};
|
||||
|
||||
function ajaxifyAnchors() {
|
||||
@@ -424,7 +414,9 @@ $(document).ready(function () {
|
||||
});
|
||||
}
|
||||
|
||||
templates.registerLoader(ajaxify.loadTemplate);
|
||||
require(['benchpress'], function (Benchpress) {
|
||||
Benchpress.registerLoader(ajaxify.loadTemplate);
|
||||
});
|
||||
|
||||
if (window.history && window.history.pushState) {
|
||||
// Progressive Enhancement, ajaxify available only to modern browsers
|
||||
@@ -432,9 +424,4 @@ $(document).ready(function () {
|
||||
}
|
||||
|
||||
app.load();
|
||||
|
||||
$('[type="text/tpl"][data-template]').each(function () {
|
||||
templates.cache[$(this).attr('data-template')] = $('<div/>').html($(this).html()).text();
|
||||
$(this).parent().remove();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user