-
-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Gabor Boros <[email protected]>
- Loading branch information
1 parent
b0a8594
commit a379d4d
Showing
32 changed files
with
354 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
layout: api-command | ||
language: Java | ||
permalink: api/java/format/ | ||
command: format | ||
io: | ||
- - r | ||
- string | ||
related_commands: | ||
match: match/ | ||
split: split/ | ||
upcase: upcase/ | ||
downcase: downcase/ | ||
--- | ||
|
||
# Command syntax # | ||
|
||
{% apibody %} | ||
r.format(string, object) → string | ||
{% endapibody %} | ||
|
||
# Description # | ||
|
||
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. | ||
|
||
__Example:__ Using simple parameters for formatting. | ||
|
||
```java | ||
r.format("{name} loves {candy}.", | ||
r.hashMap("name", "Bob").with("candy", "candy floss") | ||
).run(conn, callback) | ||
``` | ||
|
||
Result: | ||
|
||
```java | ||
"Bob loves candy floss." | ||
``` | ||
|
||
__Example:__ Using row for formatting. | ||
|
||
```java | ||
r.table("movies").map({ | ||
id: r.row('id'), | ||
ratings: r.http(r.format('http://example.com/movies/?title={title}&release={year}', r.row)) | ||
}) | ||
``` | ||
|
||
Result: | ||
|
||
```java | ||
// `ratings` is the result of the HTTP request | ||
[{ id: 1, ratings: { positive: 99, negative: 0 }}] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
layout: api-command | ||
language: JavaScript | ||
permalink: api/javascript/format/ | ||
command: format | ||
io: | ||
- - r | ||
- string | ||
related_commands: | ||
match: match/ | ||
split: split/ | ||
upcase: upcase/ | ||
downcase: downcase/ | ||
--- | ||
|
||
# Command syntax # | ||
|
||
{% apibody %} | ||
r.format(string, object) → string | ||
{% endapibody %} | ||
|
||
# Description # | ||
|
||
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. | ||
|
||
__Example:__ Using simple parameters for formatting. | ||
|
||
```js | ||
r.format("{name} loves {candy}.", { | ||
"name": "Bob", | ||
"candy": "candy floss", | ||
}).run(conn, callback) | ||
``` | ||
|
||
Result: | ||
|
||
```js | ||
"Bob loves candy floss." | ||
``` | ||
|
||
__Example:__ Using row for formatting. | ||
|
||
```js | ||
r.table("movies").map({ | ||
id: r.row('id'), | ||
ratings: r.http(r.format('http://example.com/movies/?title={title}&release={year}', r.row)) | ||
}) | ||
``` | ||
|
||
Result: | ||
|
||
```js | ||
// `ratings` is the result of the HTTP request | ||
[{ id: 1, ratings: { positive: 99, negative: 0 }}] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.