|
|
|
@ -4,6 +4,7 @@ const yaml = require('js-yaml');
|
|
|
|
|
const serialize = require('serialize-javascript');
|
|
|
|
|
const nunjucks = require('nunjucks');
|
|
|
|
|
const { filter } = require('lodash');
|
|
|
|
|
const jsesc = require('jsesc');
|
|
|
|
|
const argv = require('cac')().parse();
|
|
|
|
|
const { findFileSync } = require('@hydrooj/utils/lib/utils');
|
|
|
|
|
const status = require('@hydrooj/utils/lib/status');
|
|
|
|
@ -66,6 +67,7 @@ class Nunjucks extends nunjucks.Environment {
|
|
|
|
|
this.addFilter('ansi', (self) => misc.ansiToHtml(self));
|
|
|
|
|
this.addFilter('base64_encode', (s) => Buffer.from(s).toString('base64'));
|
|
|
|
|
this.addFilter('base64_decode', (s) => Buffer.from(s, 'base64').toString());
|
|
|
|
|
this.addFilter('jsesc', (self) => jsesc(self, { isScriptContext: true }));
|
|
|
|
|
this.addFilter('bitand', (self, val) => self & val);
|
|
|
|
|
this.addFilter('replaceBr', (self) => self.toString().replace(/\n/g, '<br>'));
|
|
|
|
|
this.addFilter('toString', (self) => (typeof self === 'string' ? self : JSON.stringify(self, replacer)));
|
|
|
|
|