derby-templates
Advanced tools
Comparing version 0.1.11 to 0.1.12
@@ -22,2 +22,3 @@ var serializeObject = require('serialize-object'); | ||
exports.SequenceExpression = SequenceExpression; | ||
exports.ScopedModelExpression = ScopedModelExpression; | ||
@@ -532,6 +533,41 @@ function lookup(segments, value) { | ||
SequenceExpression.prototype.dependencies = function(context, forInnerPath) { | ||
var last = this.args[this.args.length - 1]; | ||
return last.dependencies(context, forInnerPath); | ||
var dependencies = []; | ||
for (var i = 0, len = this.args.length; i < len; i++) { | ||
var argDependencies = this.args[i].dependencies(context, forInnerPath); | ||
for (var j = 0, jLen = argDependencies.length; j < jLen; j++) { | ||
dependencies.push(argDependencies[j]); | ||
} | ||
} | ||
return dependencies; | ||
}; | ||
function ScopedModelExpression(expression, meta) { | ||
this.expression = expression; | ||
this.meta = meta; | ||
} | ||
ScopedModelExpression.prototype = new Expression(); | ||
ScopedModelExpression.prototype.type = 'ScopedModelExpression'; | ||
ScopedModelExpression.prototype.serialize = function() { | ||
return serializeObject.instance(this, this.expression, this.meta); | ||
}; | ||
// Return a scoped model instead of the value | ||
ScopedModelExpression.prototype.get = function(context) { | ||
var segments = this.pathSegments(context); | ||
if (!segments) return; | ||
return context.controller.model.scope(segments.join('.')); | ||
}; | ||
// Delegate other methods to the inner expression | ||
ScopedModelExpression.prototype.resolve = function(context) { | ||
return this.expression.resolve(context); | ||
}; | ||
ScopedModelExpression.prototype.dependencies = function(context, forInnerPath) { | ||
return this.expression.dependencies(context, forInnerPath); | ||
}; | ||
ScopedModelExpression.prototype.pathSegments = function(context) { | ||
return this.expression.pathSegments(context); | ||
}; | ||
ScopedModelExpression.prototype.set = function(context, value) { | ||
return this.expression.set(context, value); | ||
}; | ||
function outerDependency(expression, context, forInnerPath) { | ||
@@ -538,0 +574,0 @@ if (forInnerPath) return; |
{ | ||
"name": "derby-templates", | ||
"version": "0.1.11", | ||
"version": "0.1.12", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48123
1327