mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
ui: re-impl #1094
This commit is contained in:
3 files changed
+8
-3
No files matched your search
@@ -47,3 +47,8 @@ export function* paginate(page: number, numPages: number) {
|
||||
if (page < numPages - 1) yield ['last', numPages];
|
||||
}
|
||||
}
|
||||
|
||||
export function buildQueryString(obj: Record<string, any>) {
|
||||
return Object.entries(obj).filter(([key, value]) => value && !key.startsWith('__'))
|
||||
.map(([key, value]) => `${key}=${encodeURIComponent(value)}`).join('&');
|
||||
}
|
||||
@@ -130,7 +130,7 @@ class Nunjucks extends nunjucks.Environment {
|
||||
this.addGlobal('instanceof', (a, b) => a instanceof b);
|
||||
this.addGlobal('paginate', misc.paginate);
|
||||
this.addGlobal('size', misc.size);
|
||||
this.addGlobal('utils', { status, getAlphabeticId });
|
||||
this.addGlobal('utils', { status, getAlphabeticId, buildQueryString: misc.buildQueryString });
|
||||
this.addGlobal('avatarUrl', avatar);
|
||||
this.addGlobal('formatSeconds', misc.formatSeconds);
|
||||
this.addGlobal('model', global.Hydro.model);
|
||||
|
||||
Reference in new issue
Block a user