Merge pull request #5941 from NodeBB/fix-5934

Fix #5934: Use .js instead of .jst
v1.18.x
Andrew Rodrigues 7 years ago committed by GitHub
commit ab765c5407

@ -330,7 +330,7 @@ $(document).ready(function () {
};
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);
throw err;
});

@ -14,11 +14,11 @@ function filterDirectories(directories) {
// get the relative path
return dir.replace(/^.*(admin.*?).tpl$/, '$1');
}).filter(function (dir) {
// exclude .jst files
// exclude .js files
// exclude partials
// only include subpaths
// exclude category.tpl, group.tpl, category-analytics.tpl
return !dir.endsWith('.jst') &&
return !dir.endsWith('.js') &&
!dir.includes('/partials/') &&
/\/.*\//.test(dir) &&
!/manage\/(category|group|category-analytics)$/.test(dir);

@ -35,9 +35,9 @@ function renderEmail(req, res, next) {
file.walk(emailsPath, next);
},
function (emails, next) {
// exclude .jst files
// exclude .js files
emails = emails.filter(function (email) {
return !email.endsWith('.jst');
return !email.endsWith('.js');
});
async.map(emails, function (email, next) {

@ -76,7 +76,7 @@ Templates.compile = function (callback) {
}, next);
},
function (next) {
rimraf(path.join(viewsPath, '*.jst'), next);
rimraf(path.join(viewsPath, '*.js'), next);
},
function (next) {
winston.verbose('[meta/templates] Successfully compiled templates.');

@ -192,7 +192,7 @@ middleware.delayLoading = function (req, res, next) {
var viewsDir = nconf.get('views_dir');
middleware.templatesOnDemand = function (req, res, next) {
var filePath = req.filePath || path.join(viewsDir, req.path);
if (!filePath.endsWith('.jst')) {
if (!filePath.endsWith('.js')) {
return next();
}
@ -205,7 +205,7 @@ middleware.templatesOnDemand = function (req, res, next) {
return next();
}
fs.readFile(filePath.replace(/\.jst$/, '.tpl'), cb);
fs.readFile(filePath.replace(/\.js$/, '.tpl'), cb);
},
function (source, cb) {
Benchpress.precompile({

@ -1,5 +1,5 @@
<script>
define('/assets/templates/500.jst', function () {
define('/assets/templates/500.js', function () {
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>' +
helpers.__escape(get(context && context['path'])) + '</p>\n\t' +

@ -122,7 +122,7 @@ function setupExpressApp(app, callback) {
var viewsDir = nconf.get('views_dir');
app.engine('tpl', function (filepath, data, next) {
filepath = filepath.replace(/\.tpl$/, '.jst');
filepath = filepath.replace(/\.tpl$/, '.js');
middleware.templatesOnDemand({
filePath: filepath,

@ -14,10 +14,10 @@ describe('admin search', function () {
]);
done();
});
it('should exclude .jst files', function (done) {
it('should exclude .js files', function (done) {
assert.deepEqual(search.filterDirectories([
'hfjksfd/fdsgagag/admin/gdhgfsdg/sggag.tpl',
'dfahdfsgf/admin/hgkfds/fdhsdfh.jst',
'dfahdfsgf/admin/hgkfds/fdhsdfh.js',
]), [
'admin/gdhgfsdg/sggag',
]);

Loading…
Cancel
Save