Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lib/de.block.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,15 @@ de.Block.prototype.run = function(params, context) {
});

var options = this.options;
var _params = (options.params) ? options.params(params, context) : params;

// Проверяем гвард, если он есть.
if ( options.guard && !options.guard(params, context) ) {
if ( options.guard && !options.guard(_params, context) ) {
return promise.resolve( new de.Result.Value(null) );
}

if (options.before) {
options.before(params, context);
options.before(_params, context);
}

var running;
Expand All @@ -219,7 +220,7 @@ de.Block.prototype.run = function(params, context) {
var key;
if (options.key) {
// Вычисляем ключ.
key = options.key(params, context);
key = options.key(_params, context);

// Смотрим, не закэширован ли блок с таким же ключом.
var cached = _results[key];
Expand All @@ -238,7 +239,6 @@ de.Block.prototype.run = function(params, context) {

if (!running) {
// Если блок все-таки не закэширован, запускаем его.
var _params = (options.params) ? options.params(params, context) : params;
var running = this._run(_params, context);

// Если определен таймаут для блока.
Expand Down Expand Up @@ -303,15 +303,15 @@ de.Block.prototype.run = function(params, context) {
}

if (options.after) {
options.after(params, context, result);
options.after(_params, context, result);
}

if (options.result) {
result = new de.Result.Value( options.result( result.object(), context, params ) );
result = new de.Result.Value( options.result( result.object(), context, _params ) );
}

if ( options.template && !(result instanceof de.Result.Error) ) {
var filename = that.resolveFilename( options.template(params, context) );
var filename = that.resolveFilename( options.template(_params, context) );

de.file.eval(filename, 'de', de.sandbox, context)
.done(function(template) {
Expand Down