mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
feature: support toLiquid, working on #81
This commit is contained in:
@@ -63,7 +63,10 @@ var Scope = {
|
||||
} else {
|
||||
if (typeof obj.to_liquid === 'function') {
|
||||
obj = obj.to_liquid()
|
||||
} else if (typeof obj.toLiquid === 'function') {
|
||||
obj = obj.toLiquid()
|
||||
}
|
||||
|
||||
if (key === 'size' && (_.isArray(obj) || _.isString(obj))) {
|
||||
val = obj.length
|
||||
} else {
|
||||
|
||||
@@ -11,8 +11,12 @@ function isString (value) {
|
||||
}
|
||||
|
||||
function stringify (value) {
|
||||
if (value && typeof value.to_liquid === 'function') {
|
||||
return stringify(value.to_liquid())
|
||||
if (!isNil(value)) {
|
||||
if (typeof value.to_liquid === 'function') {
|
||||
return stringify(value.to_liquid())
|
||||
} else if (typeof value.toLiquid === 'function') {
|
||||
return stringify(value.toLiquid())
|
||||
}
|
||||
}
|
||||
if (isString(value)) {
|
||||
return value
|
||||
|
||||
Reference in New Issue
Block a user