MisskeyPagesで値が0の変数が表示されない問題を修正

This commit is contained in:
syuilo
2019-04-29 11:08:35 +09:00
parent e86d0007c6
commit c886c09cdb
2 changed files with 9 additions and 4 deletions

View File

@@ -31,6 +31,7 @@ class Script {
constructor(aiScript) {
this.aiScript = aiScript;
this.vars = this.aiScript.evaluateVars();
console.log(this.vars);
}
public reEval() {
@@ -38,8 +39,10 @@ class Script {
}
public interpolate(str: string) {
return str.replace(/\{(.+?)\}/g, match =>
(this.vars.find(x => x.name === match.slice(1, -1).trim()).value || '').toString());
return str.replace(/\{(.+?)\}/g, match => {
const v = this.vars.find(x => x.name === match.slice(1, -1).trim()).value;
return v == null ? 'NULL' : v.toString();
});
}
}