mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
2.1.0
This commit is contained in:
Vendored
+12
-3
@@ -37,8 +37,13 @@ var filters = {
|
||||
return Array.prototype.concat.call(v, arg);
|
||||
},
|
||||
'date': function date(v, arg) {
|
||||
if (v === 'now') v = new Date();
|
||||
return v instanceof Date ? strftime(v, arg) : '';
|
||||
var date = v;
|
||||
if (v === 'now') {
|
||||
date = new Date();
|
||||
} else if (_.isString(v)) {
|
||||
date = new Date(v);
|
||||
}
|
||||
return isValidDate(date) ? strftime(date, arg) : v;
|
||||
},
|
||||
'default': function _default(v, arg) {
|
||||
return isTruthy(v) ? v : arg;
|
||||
@@ -203,6 +208,10 @@ function registerAll(liquid) {
|
||||
});
|
||||
}
|
||||
|
||||
function isValidDate(date) {
|
||||
return date instanceof Date && !isNaN(date.getTime());
|
||||
}
|
||||
|
||||
registerAll.filters = filters;
|
||||
module.exports = registerAll;
|
||||
|
||||
@@ -921,7 +930,7 @@ var Scope = {
|
||||
},
|
||||
get: function get(str) {
|
||||
if (str === 'liquid') {
|
||||
throw new Error('NO LONGER SUPPORTED: use scope.opts instread of scope.get("liquid")');
|
||||
throw new Error('NO LONGER SUPPORTED: use scope.opts instead of scope.get("liquid")');
|
||||
}
|
||||
try {
|
||||
return this.getPropertyByPath(this.scopes, str);
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user