From eea6afb3fe4638325679fdd2189e71cf53919db3 Mon Sep 17 00:00:00 2001 From: rickcole Date: Tue, 30 Jun 2020 21:38:30 +0800 Subject: [PATCH] =?UTF-8?q?isIn=20=E4=B9=9F=E8=A6=81=E6=94=B9=E4=B8=8B?= 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 d88e30581..2d31cb0bc 100644 --- a/src/utils/tpl-builtin.ts +++ b/src/utils/tpl-builtin.ts @@ -42,7 +42,7 @@ const entityMap: { '/': '/' }; export const escapeHtml = (str: string) => - String(str).replace(/[&<>"'\/]/g, function(s) { + String(str).replace(/[&<>"'\/]/g, function (s) { return entityMap[s]; }); @@ -218,13 +218,13 @@ export const filters: { Array.isArray(input) ? input.map(item => resolveVariable(path, item) || item) : resolveVariable(path, input) || input, - str2date: function(input, inputFormat = 'X', outputFormat = 'X') { + str2date: function (input, inputFormat = 'X', outputFormat = 'X') { return input ? filterDate(input, this, inputFormat).format(outputFormat) : ''; }, asArray: input => (Array.isArray(input) ? input : input ? [input] : input), - filter: function(input, keys, expOrDirective, arg1) { + filter: function (input, keys, expOrDirective, arg1) { if (!Array.isArray(input) || !keys || !expOrDirective) { return input; } @@ -243,7 +243,7 @@ export const filters: { fn = value => arg1 == value; } else if (directive === 'isIn') { let list: Array = arg1 ? getStrOrVariable(arg1, this) : []; - list = Array.isArray(list) ? list : []; + list = Array.isArray(list) ? list : [list]; fn = value => !!~list.indexOf(value); } else if (directive === 'notIn') { let list: Array = arg1 ? getStrOrVariable(arg1, this) : []; @@ -284,7 +284,7 @@ export const filters: { return decodeURIComponent( atob(str) .split('') - .map(function(c) { + .map(function (c) { return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); }) .join('')