Comparing version 0.6.2 to 0.6.3
{ | ||
"name": "bemer", | ||
"description": "Template engine. BEMJSON to HTML processor.", | ||
"version": "0.6.2", | ||
"version": "0.6.3", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "ignore": [ |
@@ -174,3 +174,3 @@ definer('Template', /** @exports Template */ function(Match, classify, Node, Selector, Helpers, object, string, is) { | ||
_classifyModes: function() { | ||
return classify(classify(this._getBaseProps()), this._modes); | ||
return classify(classify(this._getBaseModes()), this._functionifyModes(this._modes)); | ||
}, | ||
@@ -184,7 +184,30 @@ | ||
*/ | ||
_getBaseProps: function() { | ||
return object.extend(this._getDefaultModes(), this._helpers.get()); | ||
_getBaseModes: function() { | ||
return object.extend(this._functionifyModes(this._getDefaultModes()), this._helpers.get()); | ||
}, | ||
/** | ||
* Обернуть все поля в функции. | ||
* | ||
* Все поля должны являться функциями для | ||
* возможности вызова `__base` в любой ситуации. | ||
* | ||
* Поля, не являющиеся функциями, оборачиваются | ||
* в анонимную функцию со свойством `__wrapped__`. | ||
* | ||
* @private | ||
* @param {object} mods Поля | ||
* @returns {object} | ||
*/ | ||
_functionifyModes: function(mods) { | ||
object.each(mods, function(name, val) { | ||
if(!is.function(val)) { | ||
mods[name] = function() { return val; }; | ||
mods[name].__wrapped__ = true; | ||
} | ||
}); | ||
return mods; | ||
}, | ||
/** | ||
* Получить стандартные моды. | ||
@@ -224,5 +247,5 @@ * | ||
_getMode: function(modes, bemjson, name) { | ||
var isValFunc = is.function(modes[name]), | ||
var isValFunc = !modes[name].__wrapped__, | ||
bemjsonVal = bemjson[name], | ||
val = isValFunc ? modes[name].call(modes, bemjsonVal) : modes[name], | ||
val = modes[name].call(modes, bemjsonVal), | ||
priorityVal = this._getPriorityValue(isValFunc, val, bemjsonVal); | ||
@@ -229,0 +252,0 @@ |
{ | ||
"name": "bemer", | ||
"description": "Template engine. BEMJSON to HTML processor.", | ||
"version": "0.6.2", | ||
"version": "0.6.3", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
@@ -113,3 +113,3 @@ # Bemer — БЭМ-шаблонизатор | ||
- [Наследование шаблонов](#Наследование-шаблонов) | ||
- [Обращение к родительскому методу через `this.__base`](#Обращение-к-родительскому-методу-через-this__base) | ||
- [Получение предыдущего значения поля через `this.__base`](#Получение-предыдущего-значения-поля-через-this__base) | ||
- [Метод `config`](#Метод-config) | ||
@@ -786,5 +786,6 @@ - [Изменение настроек шаблонизации](#Изменение-настроек-шаблонизации) | ||
###### Обращение к родительскому методу через `this.__base` | ||
###### Получение предыдущего значения поля через `this.__base` | ||
При декларации функций на одно поле в нескольких шаблонах становится доступен вызов базовой реализации метода. | ||
При наследовании шаблонов есть возможность получить | ||
предыдущее значение поля. | ||
@@ -795,3 +796,3 @@ Блок `text` формирует своё содержимое по цепочке шаблонов: | ||
bemer | ||
.match('text', { content: function() { return 'Hello'; }}) | ||
.match('text', { content: 'Hello' }) | ||
.match('text', { content: function() { return this.__base() + ' world'; }}) | ||
@@ -798,0 +799,0 @@ .match('text', { content: function() { return this.__base() + '!'; }}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
541309
5357
1274