Skip to content

Commit

Permalink
Docs: notes about arg types in escaping functions
Browse files Browse the repository at this point in the history
  • Loading branch information
miripiruni committed Dec 8, 2016
1 parent 1977ee8 commit ae3ecc5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
16 changes: 13 additions & 3 deletions docs/en/6-templates-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ Result of BEMHTML templating:
this.xmlEscape(str)
```

Returns the passed `str` string with the following XML symbols escaped: `&`, `<`, `>`.
Returns the passed `str` string with the following XML symbols escaped: `&`,
`<`, `>`. Normaly, expected that `str` is a `String`. But if `str` is
`undefined`, `Null` or `NaN` an empty string returned. If `str` is of any other
type it will be casted to String before escaping.

Usage example:

Expand Down Expand Up @@ -114,7 +117,11 @@ Result of BEMHTML templating:
this.attrEscape(str)
```

Returns the passed `str` string with the following characters for XML and HTML attributes escaped: `"` and `&`.
Returns the passed `str` string with the following characters for XML and HTML
attributes escaped: `"` and `&`. Normaly, expected that `str` is a `String`.
But if `str` is `undefined`, `Null` or `NaN` type you get empty string.
If `str` is any other type you get native casting from it type to `String`
before escaping.

#### jsAttrEscape

Expand All @@ -126,7 +133,10 @@ Returns the passed `str` string with the following characters for XML and HTML a
this.jsAttrEscape(str)
```

Returns the passed `str` string with the following characters escaped: `'` and `&`.
Returns the passed `str` string with the following characters escaped: `'` and
`&`. Normaly, expected that `str` is a `String`. But if `str` is `undefined`,
`Null` or `NaN` type you get empty string. If `str` is any other type you get
native casting from it type to `String` before escaping.

By default, input data from the [`js`](4-data.md#js) field and data from the [`js`](5-templates-syntax.md#js) mode are escaped using this function.

Expand Down
13 changes: 11 additions & 2 deletions docs/ru/6-templates-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ block('company').attr()(function() {
this.xmlEscape(str)
```

Возвращает переданную строку `str` с заэкранированными символами XML: `&`, `<`, `>`.
Возвращает переданную строку `str` с заэкранированными символами XML: `&`, `<`,
`>`. Ожидается, что `str` это строка. Но если `str` это `undefined`,
`Null` или `NaN`, то функция возвратит пустую строку. Если `str` любого другого
типа, то перед экранированием этот тип будет приведен к строке.

Пример использования:

Expand Down Expand Up @@ -112,7 +115,10 @@ block('button').def()(function() {
this.attrEscape(str)
```

Возвращает переданную строку `str` с заэкранированными символами XML- и HTML-атрибутов: `"` и `&`.
Возвращает переданную строку `str` с заэкранированными символами XML- и
HTML-атрибутов: `"` и `&`. Ожидается, что `str` это строка. Но если `str` это
`undefined`, `Null` или `NaN`, то функция возвратит пустую строку. Если `str`
любого другого типа, то перед экранированием этот тип будет приведен к строке.

#### jsAttrEscape

Expand All @@ -125,6 +131,9 @@ this.jsAttrEscape(str)
```

Возвращает переданную строку `str` с заэкранированными символами: `'` и `&`.
Ожидается, что `str` это строка. Но если `str` это `undefined`, `Null` или
`NaN`, то функция возвратит пустую строку. Если `str` любого другого типа, то
перед экранированием этот тип будет приведен к строке.

По умолчанию входные данные из поля [`js`](4-data.md#js) и данные из режима [`js`](5-templates-syntax.md#js) экранируются этой функцией.

Expand Down

0 comments on commit ae3ecc5

Please sign in to comment.