Skip to content

Commit a379d4d

Browse files
committed
docs: update format docs
Signed-off-by: Gabor Boros <gabor.brs@gmail.com>
1 parent b0a8594 commit a379d4d

32 files changed

+354
-205
lines changed

_jekyll/_data/api_java.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@
219219
permalink: upcase
220220
- name: downcase
221221
permalink: downcase
222-
- name: fmt
223-
permalink: fmt
222+
- name: format
223+
permalink: format
224224
- section:
225225
name: Math and logic
226226
commands:

_jekyll/_data/api_javascript.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@
219219
permalink: upcase
220220
- name: downcase
221221
permalink: downcase
222-
- name: fmt
223-
permalink: fmt
222+
- name: format
223+
permalink: format
224224
- section:
225225
name: Math and logic
226226
commands:

_jekyll/_data/api_python.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@
217217
permalink: upcase
218218
- name: downcase
219219
permalink: downcase
220-
- name: fmt
221-
permalink: fmt
220+
- name: format
221+
permalink: format
222222
- section:
223223
name: Math and logic
224224
commands:

_jekyll/_data/api_ruby.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@
215215
permalink: upcase
216216
- name: downcase
217217
permalink: downcase
218-
- name: fmt
219-
permalink: fmt
218+
- name: format
219+
permalink: format
220220
- section:
221221
name: Math and logic
222222
commands:

api/java/index.md

+26-8
Original file line numberDiff line numberDiff line change
@@ -1932,27 +1932,45 @@ Result:
19321932

19331933
[Read more about this command &rarr;](split/)
19341934

1935-
## [fmt](fmt/) ##
1935+
## [format](format/) ##
19361936

19371937
{% apibody %}
1938-
r.fmt(string, object) &rarr; string
1938+
r.format(string, object) &rarr; string
19391939
{% endapibody %}
19401940

1941-
Formats a template string based on a string-string key-value object.
1941+
Format command takes a string as a template and formatting parameters as an object. The parameters in the template string must exist as keys in the object, otherwise, an error raised. The template must be a string literal and cannot be the result of other commands.
19421942

1943-
__Example:__
1943+
__Example:__ Using simple parameters for formatting.
19441944

1945-
```js
1946-
r.fmt("{name} loves {candy}.", {"name": "Bob", "candy": "candy floss"}).run(conn, callback)
1945+
```java
1946+
r.format("{name} loves {candy}.",
1947+
r.hashMap("name", "Bob").with("candy", "candy floss")
1948+
).run(conn, callback)
19471949
```
19481950

19491951
Result:
19501952

1951-
```js
1953+
```java
19521954
"Bob loves candy floss."
19531955
```
19541956

1955-
[Read more about this command &rarr;](fmt/)
1957+
__Example:__ Using row for formatting.
1958+
1959+
```java
1960+
r.table("movies").map({
1961+
id: r.row('id'),
1962+
ratings: r.http(r.format('http://example.com/movies/?title={title}&release={year}', r.row))
1963+
})
1964+
```
1965+
1966+
Result:
1967+
1968+
```java
1969+
// `ratings` is the result of the HTTP request
1970+
[{ id: 1, ratings: { positive: 99, negative: 0 }}]
1971+
```
1972+
1973+
[Read more about this command &rarr;](format/)
19561974

19571975
## [upcase](upcase/) ##
19581976

api/java/string-manipulation/downcase.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ related_commands:
77
upcase: upcase/
88
match: match/
99
split: split/
10-
fmt: fmt/
10+
format: format/
1111
---
1212

1313
# Command syntax #

api/java/string-manipulation/fmt.md

-38
This file was deleted.
+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
layout: api-command
3+
language: Java
4+
permalink: api/java/format/
5+
command: format
6+
io:
7+
- - r
8+
- string
9+
related_commands:
10+
match: match/
11+
split: split/
12+
upcase: upcase/
13+
downcase: downcase/
14+
---
15+
16+
# Command syntax #
17+
18+
{% apibody %}
19+
r.format(string, object) &rarr; string
20+
{% endapibody %}
21+
22+
# Description #
23+
24+
Format command takes a string as a template and formatting parameters as an object. The parameters in the template string must exist as keys in the object, otherwise, an error raised. The template must be a string literal and cannot be the result of other commands.
25+
26+
__Example:__ Using simple parameters for formatting.
27+
28+
```java
29+
r.format("{name} loves {candy}.",
30+
r.hashMap("name", "Bob").with("candy", "candy floss")
31+
).run(conn, callback)
32+
```
33+
34+
Result:
35+
36+
```java
37+
"Bob loves candy floss."
38+
```
39+
40+
__Example:__ Using row for formatting.
41+
42+
```java
43+
r.table("movies").map({
44+
id: r.row('id'),
45+
ratings: r.http(r.format('http://example.com/movies/?title={title}&release={year}', r.row))
46+
})
47+
```
48+
49+
Result:
50+
51+
```java
52+
// `ratings` is the result of the HTTP request
53+
[{ id: 1, ratings: { positive: 99, negative: 0 }}]
54+
```

api/java/string-manipulation/match.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ related_commands:
1010
upcase: upcase/
1111
downcase: downcase/
1212
split: split/
13-
fmt: fmt/
13+
format: format/
1414
---
1515

1616
# Command syntax #

api/java/string-manipulation/split.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ related_commands:
77
upcase: upcase/
88
downcase: downcase/
99
match: match/
10-
fmt: fmt/
10+
format: format/
1111
---
1212

1313
# Command syntax #

api/java/string-manipulation/upcase.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ related_commands:
77
downcase: downcase/
88
match: match/
99
split: split/
10-
fmt: fmt/
10+
format: format/
1111
---
1212

1313
# Command syntax #

api/javascript/index.md

+25-6
Original file line numberDiff line numberDiff line change
@@ -2009,18 +2009,21 @@ Result:
20092009

20102010
[Read more about this command &rarr;](split/)
20112011

2012-
## [fmt](fmt/) ##
2012+
## [format](format/) ##
20132013

20142014
{% apibody %}
2015-
r.fmt(string, object) &rarr; string
2015+
r.format(string, object) &rarr; string
20162016
{% endapibody %}
20172017

2018-
Formats a template string based on a string-string key-value object.
2018+
Format command takes a string as a template and formatting parameters as an object. The parameters in the template string must exist as keys in the object, otherwise, an error raised. The template must be a string literal and cannot be the result of other commands.
20192019

2020-
__Example:__
2020+
__Example:__ Using simple parameters for formatting.
20212021

20222022
```js
2023-
r.fmt("{name} loves {candy}.", {"name": "Bob", "candy": "candy floss"}).run(conn, callback)
2023+
r.format("{name} loves {candy}.", {
2024+
"name": "Bob",
2025+
"candy": "candy floss",
2026+
}).run(conn, callback)
20242027
```
20252028

20262029
Result:
@@ -2029,7 +2032,23 @@ Result:
20292032
"Bob loves candy floss."
20302033
```
20312034

2032-
[Read more about this command &rarr;](fmt/)
2035+
__Example:__ Using row for formatting.
2036+
2037+
```js
2038+
r.table("movies").map({
2039+
id: r.row('id'),
2040+
ratings: r.http(r.format('http://example.com/movies/?title={title}&release={year}', r.row))
2041+
})
2042+
```
2043+
2044+
Result:
2045+
2046+
```js
2047+
// `ratings` is the result of the HTTP request
2048+
[{ id: 1, ratings: { positive: 99, negative: 0 }}]
2049+
```
2050+
2051+
[Read more about this command &rarr;](format/)
20332052

20342053
## [upcase](upcase/) ##
20352054

api/javascript/string-manipulation/downcase.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ related_commands:
1010
upcase: upcase/
1111
match: match/
1212
split: split/
13-
fmt: fmt/
13+
format: format/
1414
---
1515

1616
# Command syntax #

api/javascript/string-manipulation/fmt.md

-39
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
layout: api-command
3+
language: JavaScript
4+
permalink: api/javascript/format/
5+
command: format
6+
io:
7+
- - r
8+
- string
9+
related_commands:
10+
match: match/
11+
split: split/
12+
upcase: upcase/
13+
downcase: downcase/
14+
---
15+
16+
# Command syntax #
17+
18+
{% apibody %}
19+
r.format(string, object) &rarr; string
20+
{% endapibody %}
21+
22+
# Description #
23+
24+
Format command takes a string as a template and formatting parameters as an object. The parameters in the template string must exist as keys in the object, otherwise, an error raised. The template must be a string literal and cannot be the result of other commands.
25+
26+
__Example:__ Using simple parameters for formatting.
27+
28+
```js
29+
r.format("{name} loves {candy}.", {
30+
"name": "Bob",
31+
"candy": "candy floss",
32+
}).run(conn, callback)
33+
```
34+
35+
Result:
36+
37+
```js
38+
"Bob loves candy floss."
39+
```
40+
41+
__Example:__ Using row for formatting.
42+
43+
```js
44+
r.table("movies").map({
45+
id: r.row('id'),
46+
ratings: r.http(r.format('http://example.com/movies/?title={title}&release={year}', r.row))
47+
})
48+
```
49+
50+
Result:
51+
52+
```js
53+
// `ratings` is the result of the HTTP request
54+
[{ id: 1, ratings: { positive: 99, negative: 0 }}]
55+
```

api/javascript/string-manipulation/match.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ related_commands:
1010
upcase: upcase/
1111
downcase: downcase/
1212
split: split/
13-
fmt: fmt/
13+
format: format/
1414
---
1515

1616
# Command syntax #

0 commit comments

Comments
 (0)