mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: app.parseAndTranslate to always return promise
This commit is contained in:
@@ -742,23 +742,21 @@ app.cacheBuster = null;
|
|||||||
blockName = undefined;
|
blockName = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const execute = (resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
require(['translator', 'benchpress'], function (translator, Benchpress) {
|
require(['translator', 'benchpress'], function (translator, Benchpress) {
|
||||||
Benchpress.render(template, data, blockName)
|
Benchpress.render(template, data, blockName)
|
||||||
.then(rendered => translator.translate(rendered))
|
.then(rendered => translator.translate(rendered))
|
||||||
.then(translated => translator.unescape(translated))
|
.then(translated => translator.unescape(translated))
|
||||||
.then(resolve, reject);
|
.then(resolve, reject);
|
||||||
});
|
});
|
||||||
};
|
}).then((html) => {
|
||||||
|
html = $(html);
|
||||||
if (callback) {
|
if (callback && typeof callback === 'function') {
|
||||||
execute(
|
setTimeout(callback, 0, html);
|
||||||
result => setTimeout(callback, 0, $(result)),
|
|
||||||
err => console.error(err)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return new Promise(execute).then(html => $(html));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return html;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
app.showCookieWarning = function () {
|
app.showCookieWarning = function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user