diff --git a/docs/en/4-data.md b/docs/en/4-data.md index c5d14a5f..470617d5 100644 --- a/docs/en/4-data.md +++ b/docs/en/4-data.md @@ -220,6 +220,37 @@ Values are escaped:
``` +For any field value in `attrs` object templates will be applied. Example: + +```js +// BEMJSON +{ + block: 'button', + attrs: { + 'data-text': { + block: 'i-bem', + elem: 'i18n', + key: 'button-success' + } + } +} +``` + +```js +// Template +block('i-bem').elem('i18n')({ + // Here I18N.get it’s just method which returns some string + def: (node, ctx) => node.I18N.get(ctx.key) +}); +``` + +*Result of templating:* + +```html +
+``` + + ### cls `{String}` HTML class or classes (separated by spaces) that do not belong to the BEM subject domain. For example, the use of [microformats](http://microformats.org/) or semantic markup from [schema.org](https://schema.org/). diff --git a/docs/ru/4-data.md b/docs/ru/4-data.md index 2a8b92af..630f2b54 100644 --- a/docs/ru/4-data.md +++ b/docs/ru/4-data.md @@ -219,6 +219,37 @@
``` +Если любое поле объекта `attrs` содержит БЭМ-cущность (в данном случае просто объект с полями `block`/`elem`/`mods`/`elemMods`), то для такого объекта шаблонизатор попробует применить шаблоны. Пример: + +```js +// BEMJSON +{ + block: 'button', + attrs: { + 'data-text': { + block: 'i-bem', + elem: 'i18n', + key: 'button-success' + } + } +} +``` + +```js +// Шаблон +block('i-bem').elem('i18n')({ + // Здесь I18N.get просто метод, который возвратит строку + def: (node, ctx) => node.I18N.get(ctx.key) +}); +``` + +*Результат шаблонизации:* + +```html +
+``` + + ### cls `{String}` HTML-класс или классы (через пробел), не принадлежащие к предметной области БЭМ. Например, применение [микроформатов](http://microformats.org/) или семантической разметки из [schema.org](https://schema.org/).