mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
Hello airbnb
This commit is contained in:
1 parent
f9468536de
commit
8c195661d7
78 files changed
+2032
-1471
No files matched your search
+17
-24
@@ -1,34 +1,27 @@
|
||||
const
|
||||
path = require('path'),
|
||||
nunjucks = require('nunjucks'),
|
||||
markdown = require('./markdown'),
|
||||
options = require('../options'),
|
||||
perm = require('../permission'),
|
||||
builtin = require('../model/builtin'),
|
||||
model = require('../model'),
|
||||
misc = require('../lib/misc');
|
||||
const path = require('path');
|
||||
const nunjucks = require('nunjucks');
|
||||
const markdown = require('./markdown');
|
||||
const options = require('../options');
|
||||
const perm = require('../permission');
|
||||
const builtin = require('../model/builtin');
|
||||
const model = require('../model');
|
||||
const misc = require('./misc');
|
||||
|
||||
class Nunjucks extends nunjucks.Environment {
|
||||
constructor() {
|
||||
super(
|
||||
new nunjucks.FileSystemLoader(path.resolve(options.template.path)),
|
||||
{ autoescape: true, trimBlocks: true }
|
||||
{ autoescape: true, trimBlocks: true },
|
||||
);
|
||||
this.addFilter('json', function (self) {
|
||||
return JSON.stringify(self);
|
||||
}, false);
|
||||
this.addFilter('assign', function (self, data) {
|
||||
return Object.assign(self, data);
|
||||
});
|
||||
this.addFilter('markdown', function (self) {
|
||||
return markdown.render(self);
|
||||
});
|
||||
this.addFilter('json', (self) => JSON.stringify(self), false);
|
||||
this.addFilter('assign', (self, data) => Object.assign(self, data));
|
||||
this.addFilter('markdown', (self) => markdown.render(self));
|
||||
this.addFilter('gravatar_url', misc.gravatar_url);
|
||||
this.addFilter('format_size', misc.format_size);
|
||||
this.addGlobal('typeof', o => typeof o);
|
||||
this.addGlobal('typeof', (o) => typeof o);
|
||||
this.addGlobal('console', console);
|
||||
this.addGlobal('static_url', str => `/${str}`);
|
||||
this.addGlobal('reverse_url', str => str);
|
||||
this.addGlobal('static_url', (str) => `/${str}`);
|
||||
this.addGlobal('reverse_url', (str) => str);
|
||||
this.addGlobal('datetime_span', misc.datetime_span);
|
||||
this.addGlobal('paginate', misc.paginate);
|
||||
this.addGlobal('perm', perm);
|
||||
@@ -36,6 +29,6 @@ class Nunjucks extends nunjucks.Environment {
|
||||
this.addGlobal('model', model);
|
||||
}
|
||||
}
|
||||
let env = new Nunjucks();
|
||||
const env = new Nunjucks();
|
||||
|
||||
module.exports = env;
|
||||
module.exports = env;
|
||||
Reference in new issue
Block a user