mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
test cases for #32
This commit is contained in:
+5
-5
@@ -26,11 +26,11 @@ var render = {
|
||||
function renderTemplate (template) {
|
||||
if (template.type === 'tag') {
|
||||
return this.renderTag(template, scope)
|
||||
.then(partial => partial === undefined ? '' : partial)
|
||||
.then(partial => partial === undefined ? '' : partial)
|
||||
} else if (template.type === 'output') {
|
||||
return Promise.resolve()
|
||||
.then(() => this.evalOutput(template, scope))
|
||||
.then(partial => partial === undefined ? '' : stringify(partial))
|
||||
.then(() => this.evalOutput(template, scope))
|
||||
.then(partial => partial === undefined ? '' : stringify(partial))
|
||||
} else { // template.type === 'html'
|
||||
return Promise.resolve(template.value)
|
||||
}
|
||||
@@ -50,8 +50,8 @@ var render = {
|
||||
evalOutput: function (template, scope) {
|
||||
assert(scope, 'unable to evalOutput: scope undefined')
|
||||
return template.filters.reduce(
|
||||
(prev, filter) => filter.render(prev, scope),
|
||||
Syntax.evalExp(template.initial, scope))
|
||||
(prev, filter) => filter.render(prev, scope),
|
||||
Syntax.evalExp(template.initial, scope))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-16
@@ -60,10 +60,6 @@ function _assignBinary (dst, src) {
|
||||
return dst
|
||||
}
|
||||
|
||||
function isArray (value) {
|
||||
return value instanceof Array
|
||||
}
|
||||
|
||||
function echo (prefix) {
|
||||
return v => {
|
||||
console.log('[' + prefix + ']', v)
|
||||
@@ -91,16 +87,8 @@ function uniq (arr) {
|
||||
* @return {Boolean} Returns true if value is an object, else false.
|
||||
*/
|
||||
function isObject (value) {
|
||||
return value !== null && typeof value === 'object'
|
||||
}
|
||||
|
||||
/*
|
||||
* Checks if value's prototype is Object or undefined.
|
||||
* @param {any} value The value to check.
|
||||
* @return {Boolean} Returns true if value is a plain object, else false.
|
||||
*/
|
||||
function isPlainObject(value) {
|
||||
return value && !value.constructor || value.constructor === Object
|
||||
var type = typeof value
|
||||
return value != null && (type === 'object' || type === 'function')
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -126,9 +114,7 @@ function range (start, stop, step) {
|
||||
}
|
||||
|
||||
exports.isString = isString
|
||||
exports.isArray = isArray
|
||||
exports.isObject = isObject
|
||||
exports.isPlainObject = isPlainObject
|
||||
exports.isError = isError
|
||||
|
||||
exports.range = range
|
||||
|
||||
Reference in New Issue
Block a user