mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 04:25:55 +01:00
@@ -330,7 +330,7 @@ $(document).ready(function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ajaxify.loadTemplate = function (template, callback) {
|
ajaxify.loadTemplate = function (template, callback) {
|
||||||
require([config.relative_path + '/assets/templates/' + template + '.jst'], callback, function (err) {
|
require([config.relative_path + '/assets/templates/' + template + '.js'], callback, function (err) {
|
||||||
console.error('Unable to load template: ' + template);
|
console.error('Unable to load template: ' + template);
|
||||||
throw err;
|
throw err;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ function filterDirectories(directories) {
|
|||||||
// get the relative path
|
// get the relative path
|
||||||
return dir.replace(/^.*(admin.*?).tpl$/, '$1');
|
return dir.replace(/^.*(admin.*?).tpl$/, '$1');
|
||||||
}).filter(function (dir) {
|
}).filter(function (dir) {
|
||||||
// exclude .jst files
|
// exclude .js files
|
||||||
// exclude partials
|
// exclude partials
|
||||||
// only include subpaths
|
// only include subpaths
|
||||||
// exclude category.tpl, group.tpl, category-analytics.tpl
|
// exclude category.tpl, group.tpl, category-analytics.tpl
|
||||||
return !dir.endsWith('.jst') &&
|
return !dir.endsWith('.js') &&
|
||||||
!dir.includes('/partials/') &&
|
!dir.includes('/partials/') &&
|
||||||
/\/.*\//.test(dir) &&
|
/\/.*\//.test(dir) &&
|
||||||
!/manage\/(category|group|category-analytics)$/.test(dir);
|
!/manage\/(category|group|category-analytics)$/.test(dir);
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ function renderEmail(req, res, next) {
|
|||||||
file.walk(emailsPath, next);
|
file.walk(emailsPath, next);
|
||||||
},
|
},
|
||||||
function (emails, next) {
|
function (emails, next) {
|
||||||
// exclude .jst files
|
// exclude .js files
|
||||||
emails = emails.filter(function (email) {
|
emails = emails.filter(function (email) {
|
||||||
return !email.endsWith('.jst');
|
return !email.endsWith('.js');
|
||||||
});
|
});
|
||||||
|
|
||||||
async.map(emails, function (email, next) {
|
async.map(emails, function (email, next) {
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ Templates.compile = function (callback) {
|
|||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
rimraf(path.join(viewsPath, '*.jst'), next);
|
rimraf(path.join(viewsPath, '*.js'), next);
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
winston.verbose('[meta/templates] Successfully compiled templates.');
|
winston.verbose('[meta/templates] Successfully compiled templates.');
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ middleware.delayLoading = function (req, res, next) {
|
|||||||
var viewsDir = nconf.get('views_dir');
|
var viewsDir = nconf.get('views_dir');
|
||||||
middleware.templatesOnDemand = function (req, res, next) {
|
middleware.templatesOnDemand = function (req, res, next) {
|
||||||
var filePath = req.filePath || path.join(viewsDir, req.path);
|
var filePath = req.filePath || path.join(viewsDir, req.path);
|
||||||
if (!filePath.endsWith('.jst')) {
|
if (!filePath.endsWith('.js')) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,7 +205,7 @@ middleware.templatesOnDemand = function (req, res, next) {
|
|||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.readFile(filePath.replace(/\.jst$/, '.tpl'), cb);
|
fs.readFile(filePath.replace(/\.js$/, '.tpl'), cb);
|
||||||
},
|
},
|
||||||
function (source, cb) {
|
function (source, cb) {
|
||||||
Benchpress.precompile({
|
Benchpress.precompile({
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
define('/assets/templates/500.jst', function () {
|
define('/assets/templates/500.js', function () {
|
||||||
function compiled(helpers, context, get, iter, helper) {
|
function compiled(helpers, context, get, iter, helper) {
|
||||||
return '<div class="alert alert-danger">\n\t<strong>[[global:500.title]]</strong>\n\t<p>[[global:500.message]]</p>\n\t<p>' +
|
return '<div class="alert alert-danger">\n\t<strong>[[global:500.title]]</strong>\n\t<p>[[global:500.message]]</p>\n\t<p>' +
|
||||||
helpers.__escape(get(context && context['path'])) + '</p>\n\t' +
|
helpers.__escape(get(context && context['path'])) + '</p>\n\t' +
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ function setupExpressApp(app, callback) {
|
|||||||
var viewsDir = nconf.get('views_dir');
|
var viewsDir = nconf.get('views_dir');
|
||||||
|
|
||||||
app.engine('tpl', function (filepath, data, next) {
|
app.engine('tpl', function (filepath, data, next) {
|
||||||
filepath = filepath.replace(/\.tpl$/, '.jst');
|
filepath = filepath.replace(/\.tpl$/, '.js');
|
||||||
|
|
||||||
middleware.templatesOnDemand({
|
middleware.templatesOnDemand({
|
||||||
filePath: filepath,
|
filePath: filepath,
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ describe('admin search', function () {
|
|||||||
]);
|
]);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
it('should exclude .jst files', function (done) {
|
it('should exclude .js files', function (done) {
|
||||||
assert.deepEqual(search.filterDirectories([
|
assert.deepEqual(search.filterDirectories([
|
||||||
'hfjksfd/fdsgagag/admin/gdhgfsdg/sggag.tpl',
|
'hfjksfd/fdsgagag/admin/gdhgfsdg/sggag.tpl',
|
||||||
'dfahdfsgf/admin/hgkfds/fdhsdfh.jst',
|
'dfahdfsgf/admin/hgkfds/fdhsdfh.js',
|
||||||
]), [
|
]), [
|
||||||
'admin/gdhgfsdg/sggag',
|
'admin/gdhgfsdg/sggag',
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user