feat: with & for in render tag, closes #195

This commit is contained in:
harttle
2020-03-04 07:08:54 +08:00
parent aa27a6cd7b
commit 6ea6881f08
67 changed files with 1108 additions and 724 deletions
+8
View File
@@ -0,0 +1,8 @@
import { isString, isObject, isArray } from './underscore'
export function toCollection (val: any) {
if (isArray(val)) return val
if (isString(val) && val.length > 0) return [val]
if (isObject(val)) return Object.keys(val).map((key) => [key, val[key]])
return []
}
+4
View File
@@ -123,3 +123,7 @@ export function changeCase (str: string): string {
const hasLowerCase = [...str].some(ch => ch >= 'a' && ch <= 'z')
return hasLowerCase ? str.toUpperCase() : str.toLowerCase()
}
export function ellipsis (str: string, N: number): string {
return str.length > N ? str.substr(0, N - 3) + '...' : str
}