From 44fce36608b3d505dcd365fa507a1d6d126417c3 Mon Sep 17 00:00:00 2001 From: liaoxuezhi Date: Wed, 8 May 2019 19:38:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20default=20filter=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=85=B6=E4=BB=96=E7=B1=BB=E5=9E=8B=E5=AE=9A?= =?UTF-8?q?=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/tpl-builtin.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils/tpl-builtin.ts b/src/utils/tpl-builtin.ts index a5301bc2..4487c1b7 100644 --- a/src/utils/tpl-builtin.ts +++ b/src/utils/tpl-builtin.ts @@ -176,17 +176,17 @@ export const filters: { }, url_encode: input => encodeURIComponent(input), url_decode: input => decodeURIComponent(input), - default: (input, ...rest) => input || rest.map((item: any) => { + default: (input, defaultValue) => input || (() => { try { - if (item === 'undefined') { + if (defaultValue === 'undefined') { return undefined; } - return JSON.parse(item); + return JSON.parse(defaultValue); } catch (e) { - return item; + return defaultValue; } - }).join(":"), + })(), join: (input, glue) => (input && input.join ? input.join(glue) : input), split: (input, delimiter = ",") => typeof input === "string" ? input.split(delimiter) : input,