ui: Add problem_detail lang tab (#319)

This commit is contained in:
panda authored and GitHub committed 2022-03-19 15:58:37 +08:00
1 parent 5f344e140f
commit 29fbb08b4b
3 files changed
+46 -1

No files matched your search

@@ -96,6 +96,18 @@ class Nunjucks extends nunjucks.Environment {
if (s instanceof Array) s = buildContent(s, html ? 'html' : 'markdown', (str) => str.translate(language));
return ensureTag(html ? xss.process(s) : markdown.render(s));
});
this.addFilter('contentLang', (content) => {
let s = '';
try {
s = JSON.parse(content);
} catch {
s = content;
}
if (typeof s === 'object' && !(s instanceof Array)) {
return Object.keys(s);
}
return [];
});
this.addFilter('log', (self) => {
console.log(self);
return self;