From c886c09cdb2878f2b0e53939f7afce9eab71e44f Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 29 Apr 2019 11:08:35 +0900 Subject: [PATCH] =?UTF-8?q?MisskeyPages=E3=81=A7=E5=80=A4=E3=81=8C0?= =?UTF-8?q?=E3=81=AE=E5=A4=89=E6=95=B0=E3=81=8C=E8=A1=A8=E7=A4=BA=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=81=AA=E3=81=84=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/app/common/scripts/aiscript.ts | 6 ++++-- src/client/app/common/views/pages/page/page.vue | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/client/app/common/scripts/aiscript.ts b/src/client/app/common/scripts/aiscript.ts index aea89ff9a3..a3e499fc88 100644 --- a/src/client/app/common/scripts/aiscript.ts +++ b/src/client/app/common/scripts/aiscript.ts @@ -316,8 +316,10 @@ export class AiScript { @autobind private interpolate(str: string, values: { name: string, value: any }[]) { - return str.replace(/\{(.+?)\}/g, match => - (this.getVariableValue(match.slice(1, -1).trim(), values) || '').toString()); + return str.replace(/\{(.+?)\}/g, match => { + const v = this.getVariableValue(match.slice(1, -1).trim(), values); + return v == null ? 'NULL' : v.toString(); + }); } @autobind diff --git a/src/client/app/common/views/pages/page/page.vue b/src/client/app/common/views/pages/page/page.vue index 5ca58a6a4e..307ddf8db7 100644 --- a/src/client/app/common/views/pages/page/page.vue +++ b/src/client/app/common/views/pages/page/page.vue @@ -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(); + }); } }