mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
ui: Add problem_detail lang tab (#319)
This commit is contained in:
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;
|
||||
|
||||
Reference in new issue
Block a user