mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 22:23:33 +01:00
eejs: Fix straightforward ESLint errors
This commit is contained in:
parent
c89da1a9f2
commit
ebc4956277
1 changed files with 17 additions and 27 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
'use strict';
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011 RedHog (Egil Möller) <egil.moller@freecode.no>
|
* Copyright (c) 2011 RedHog (Egil Möller) <egil.moller@freecode.no>
|
||||||
*
|
*
|
||||||
|
@ -21,8 +22,8 @@
|
||||||
|
|
||||||
const ejs = require('ejs');
|
const ejs = require('ejs');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const hooks = require('../../static/js/pluginfw/hooks.js');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks.js');
|
|
||||||
const resolve = require('resolve');
|
const resolve = require('resolve');
|
||||||
const settings = require('../utils/Settings');
|
const settings = require('../utils/Settings');
|
||||||
|
|
||||||
|
@ -35,50 +36,43 @@ exports.info = {
|
||||||
args: [],
|
args: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
function getCurrentFile() {
|
const getCurrentFile = () => exports.info.file_stack[exports.info.file_stack.length - 1];
|
||||||
return exports.info.file_stack[exports.info.file_stack.length - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
function createBlockId(name) {
|
exports._init = (b, recursive) => {
|
||||||
return `${getCurrentFile().path}|${name}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
exports._init = function (b, recursive) {
|
|
||||||
exports.info.__output_stack.push(exports.info.__output);
|
exports.info.__output_stack.push(exports.info.__output);
|
||||||
exports.info.__output = b;
|
exports.info.__output = b;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports._exit = function (b, recursive) {
|
exports._exit = (b, recursive) => {
|
||||||
getCurrentFile().inherit.forEach((item) => {
|
getCurrentFile().inherit.forEach((item) => {
|
||||||
exports._require(item.name, item.args);
|
exports._require(item.name, item.args);
|
||||||
});
|
});
|
||||||
exports.info.__output = exports.info.__output_stack.pop();
|
exports.info.__output = exports.info.__output_stack.pop();
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.begin_capture = function () {
|
exports.begin_capture = () => {
|
||||||
exports.info.__output_stack.push(exports.info.__output.concat());
|
exports.info.__output_stack.push(exports.info.__output.concat());
|
||||||
exports.info.__output.splice(0, exports.info.__output.length);
|
exports.info.__output.splice(0, exports.info.__output.length);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.end_capture = function () {
|
exports.end_capture = () => {
|
||||||
const res = exports.info.__output.join('');
|
const res = exports.info.__output.join('');
|
||||||
exports.info.__output.splice.apply(
|
exports.info.__output.splice(
|
||||||
exports.info.__output,
|
0, exports.info.__output.length, ...exports.info.__output_stack.pop());
|
||||||
[0, exports.info.__output.length].concat(exports.info.__output_stack.pop()));
|
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.begin_define_block = function (name) {
|
exports.begin_define_block = (name) => {
|
||||||
exports.info.block_stack.push(name);
|
exports.info.block_stack.push(name);
|
||||||
exports.begin_capture();
|
exports.begin_capture();
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.end_define_block = function () {
|
exports.end_define_block = () => {
|
||||||
const content = exports.end_capture();
|
const content = exports.end_capture();
|
||||||
return content;
|
return content;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.end_block = function () {
|
exports.end_block = () => {
|
||||||
const name = exports.info.block_stack.pop();
|
const name = exports.info.block_stack.pop();
|
||||||
const renderContext = exports.info.args[exports.info.args.length - 1];
|
const renderContext = exports.info.args[exports.info.args.length - 1];
|
||||||
const args = {content: exports.end_define_block(), renderContext};
|
const args = {content: exports.end_define_block(), renderContext};
|
||||||
|
@ -88,12 +82,12 @@ exports.end_block = function () {
|
||||||
|
|
||||||
exports.begin_block = exports.begin_define_block;
|
exports.begin_block = exports.begin_define_block;
|
||||||
|
|
||||||
exports.inherit = function (name, args) {
|
exports.inherit = (name, args) => {
|
||||||
getCurrentFile().inherit.push({name, args});
|
getCurrentFile().inherit.push({name, args});
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.require = function (name, args, mod) {
|
exports.require = (name, args, mod) => {
|
||||||
if (args == undefined) args = {};
|
if (args == null) args = {};
|
||||||
|
|
||||||
let basedir = __dirname;
|
let basedir = __dirname;
|
||||||
let paths = [];
|
let paths = [];
|
||||||
|
@ -132,17 +126,13 @@ exports.require = function (name, args, mod) {
|
||||||
|
|
||||||
exports.info.args.push(args);
|
exports.info.args.push(args);
|
||||||
exports.info.file_stack.push({path: ejspath, inherit: []});
|
exports.info.file_stack.push({path: ejspath, inherit: []});
|
||||||
if (settings.maxAge !== 0) {
|
const res = ejs.render(template, args, {cache: settings.maxAge !== 0, filename: ejspath});
|
||||||
var res = ejs.render(template, args, {cache: true, filename: ejspath});
|
|
||||||
} else {
|
|
||||||
var res = ejs.render(template, args, {cache: false, filename: ejspath});
|
|
||||||
}
|
|
||||||
exports.info.file_stack.pop();
|
exports.info.file_stack.pop();
|
||||||
exports.info.args.pop();
|
exports.info.args.pop();
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports._require = function (name, args) {
|
exports._require = (name, args) => {
|
||||||
exports.info.__output.push(exports.require(name, args));
|
exports.info.__output.push(exports.require(name, args));
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue