mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 08:26:16 -04:00
lint: Run eslint --fix
on src/
This commit is contained in:
parent
b8d07a42eb
commit
8e5fd19db2
109 changed files with 9061 additions and 10572 deletions
|
@ -19,84 +19,84 @@
|
|||
* require("./index").require("./examples/foo.ejs")
|
||||
*/
|
||||
|
||||
var ejs = require("ejs");
|
||||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks.js");
|
||||
var resolve = require("resolve");
|
||||
var settings = require('../utils/Settings');
|
||||
const ejs = require('ejs');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks.js');
|
||||
const resolve = require('resolve');
|
||||
const settings = require('../utils/Settings');
|
||||
|
||||
const templateCache = new Map()
|
||||
const templateCache = new Map();
|
||||
|
||||
exports.info = {
|
||||
__output_stack: [],
|
||||
block_stack: [],
|
||||
file_stack: [],
|
||||
args: []
|
||||
args: [],
|
||||
};
|
||||
|
||||
function getCurrentFile() {
|
||||
return exports.info.file_stack[exports.info.file_stack.length-1];
|
||||
return exports.info.file_stack[exports.info.file_stack.length - 1];
|
||||
}
|
||||
|
||||
function createBlockId(name) {
|
||||
return getCurrentFile().path + '|' + name;
|
||||
return `${getCurrentFile().path}|${name}`;
|
||||
}
|
||||
|
||||
exports._init = function (b, recursive) {
|
||||
exports.info.__output_stack.push(exports.info.__output);
|
||||
exports.info.__output = b;
|
||||
}
|
||||
};
|
||||
|
||||
exports._exit = function (b, recursive) {
|
||||
getCurrentFile().inherit.forEach(function (item) {
|
||||
getCurrentFile().inherit.forEach((item) => {
|
||||
exports._require(item.name, item.args);
|
||||
});
|
||||
exports.info.__output = exports.info.__output_stack.pop();
|
||||
}
|
||||
};
|
||||
|
||||
exports.begin_capture = function() {
|
||||
exports.begin_capture = function () {
|
||||
exports.info.__output_stack.push(exports.info.__output.concat());
|
||||
exports.info.__output.splice(0, exports.info.__output.length);
|
||||
}
|
||||
};
|
||||
|
||||
exports.end_capture = function () {
|
||||
var res = exports.info.__output.join("");
|
||||
const res = exports.info.__output.join('');
|
||||
exports.info.__output.splice.apply(
|
||||
exports.info.__output,
|
||||
[0, exports.info.__output.length].concat(exports.info.__output_stack.pop()));
|
||||
exports.info.__output,
|
||||
[0, exports.info.__output.length].concat(exports.info.__output_stack.pop()));
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
exports.begin_define_block = function (name) {
|
||||
exports.info.block_stack.push(name);
|
||||
exports.begin_capture();
|
||||
}
|
||||
};
|
||||
|
||||
exports.end_define_block = function () {
|
||||
var content = exports.end_capture();
|
||||
const content = exports.end_capture();
|
||||
return content;
|
||||
}
|
||||
};
|
||||
|
||||
exports.end_block = function () {
|
||||
var name = exports.info.block_stack.pop();
|
||||
var renderContext = exports.info.args[exports.info.args.length-1];
|
||||
var args = {content: exports.end_define_block(), renderContext: renderContext};
|
||||
hooks.callAll("eejsBlock_" + name, args);
|
||||
const name = exports.info.block_stack.pop();
|
||||
const renderContext = exports.info.args[exports.info.args.length - 1];
|
||||
const args = {content: exports.end_define_block(), renderContext};
|
||||
hooks.callAll(`eejsBlock_${name}`, args);
|
||||
exports.info.__output.push(args.content);
|
||||
}
|
||||
};
|
||||
|
||||
exports.begin_block = exports.begin_define_block;
|
||||
|
||||
exports.inherit = function (name, args) {
|
||||
getCurrentFile().inherit.push({name:name, args:args});
|
||||
}
|
||||
getCurrentFile().inherit.push({name, args});
|
||||
};
|
||||
|
||||
exports.require = function (name, args, mod) {
|
||||
if (args == undefined) args = {};
|
||||
|
||||
var basedir = __dirname;
|
||||
var paths = [];
|
||||
let basedir = __dirname;
|
||||
let paths = [];
|
||||
|
||||
if (exports.info.file_stack.length) {
|
||||
basedir = path.dirname(getCurrentFile().path);
|
||||
|
@ -106,43 +106,43 @@ exports.require = function (name, args, mod) {
|
|||
paths = mod.paths;
|
||||
}
|
||||
|
||||
var ejspath = resolve.sync(
|
||||
name,
|
||||
{
|
||||
paths : paths,
|
||||
basedir : basedir,
|
||||
extensions : [ '.html', '.ejs' ],
|
||||
}
|
||||
)
|
||||
const ejspath = resolve.sync(
|
||||
name,
|
||||
{
|
||||
paths,
|
||||
basedir,
|
||||
extensions: ['.html', '.ejs'],
|
||||
},
|
||||
);
|
||||
|
||||
args.e = exports;
|
||||
args.require = require;
|
||||
|
||||
let template
|
||||
if (settings.maxAge !== 0){ // don't cache if maxAge is 0
|
||||
let template;
|
||||
if (settings.maxAge !== 0) { // don't cache if maxAge is 0
|
||||
if (!templateCache.has(ejspath)) {
|
||||
template = '<% e._init(__output); %>' + fs.readFileSync(ejspath).toString() + '<% e._exit(); %>';
|
||||
templateCache.set(ejspath, template)
|
||||
template = `<% e._init(__output); %>${fs.readFileSync(ejspath).toString()}<% e._exit(); %>`;
|
||||
templateCache.set(ejspath, template);
|
||||
} else {
|
||||
template = templateCache.get(ejspath)
|
||||
template = templateCache.get(ejspath);
|
||||
}
|
||||
}else{
|
||||
template = '<% e._init(__output); %>' + fs.readFileSync(ejspath).toString() + '<% e._exit(); %>';
|
||||
} else {
|
||||
template = `<% e._init(__output); %>${fs.readFileSync(ejspath).toString()}<% e._exit(); %>`;
|
||||
}
|
||||
|
||||
exports.info.args.push(args);
|
||||
exports.info.file_stack.push({path: ejspath, inherit: []});
|
||||
if(settings.maxAge !== 0){
|
||||
var res = ejs.render(template, args, { cache: true, filename: ejspath });
|
||||
}else{
|
||||
var res = ejs.render(template, args, { cache: false, filename: ejspath });
|
||||
if (settings.maxAge !== 0) {
|
||||
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.args.pop();
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
exports._require = function (name, args) {
|
||||
exports.info.__output.push(exports.require(name, args));
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue