diff --git a/docs/en/7-runtime.md b/docs/en/7-runtime.md index d67aedbb..fc3d6432 100644 --- a/docs/en/7-runtime.md +++ b/docs/en/7-runtime.md @@ -132,6 +132,28 @@ block('header').tag()(function() {
``` +If you try to call `apply()` for mode without templates, engine will lookup a +value of the corresponding field from current BEMJSON node. + +```js +// BEMJSON +{ block: 'animal', type: 'cat' } +``` + +Template: + +```js +block('animal').content()(function() { + return apply('type'); +}); +``` + +*Result of templating:* + +```html +
cat
+``` + ### applyNext ```js diff --git a/docs/ru/7-runtime.md b/docs/ru/7-runtime.md index ec9f5563..20ad3af7 100644 --- a/docs/ru/7-runtime.md +++ b/docs/ru/7-runtime.md @@ -132,6 +132,29 @@ block('header').tag()(function() { ``` +Если будет вызван `apply()` для режима для которого нет шаблонов, то +шаблонизатор попытается извлечь значение поля с соответствующим названием из +текущего узла BEMJSON-а. + +```js +// BEMJSON +{ block: 'animal', type: 'cat' } +``` + +Шаблон: + +```js +block('animal').content()(function() { + return apply('type'); +}); +``` + +*Результат шаблонизации:* + +```html +
cat
+``` + ### applyNext ```js diff --git a/test/runtime-apply-test.js b/test/runtime-apply-test.js index 7fdc571a..bdfb17c1 100644 --- a/test/runtime-apply-test.js +++ b/test/runtime-apply-test.js @@ -94,4 +94,13 @@ describe('Runtime apply()', function() { }, { block: 'b' }, undefined); }); + + it('apply(\'\') should lookup field from bemjson by default', function() { + test(function() { + block('b').def()(function() { + return apply('test'); + }); + }, { block: 'b', test: 'bemjson' }, + 'bemjson'); + }); });