mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 12:50:38 -07:00
feat: with & for in render tag, closes #195
This commit is contained in:
@@ -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 []
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user