Skip to content

docs: mention template literals in fake docs #701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/fake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ export class Fake {
/**
* Generator method for combining faker methods based on string input.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Generator method for combining faker methods based on string input.
* Generator method for combining faker methods based on static string input.

*
* This will check the given string for placeholders and replace them by calling the specified faker method.
* Note: If you just want to create a string on the fly, we recommend using string template literals instead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Note: If you just want to create a string on the fly, we recommend using string template literals instead.
* Note: If you want to create a string combining a few different faker elements, we recommend using string template literals instead of `fake`, eg. `const address = `${faker.address.zipCode} ${faker.address.city}``

* This method is useful if you wish to choose a random format from a non-executable source or persistent storage (json etc.).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* This method is useful if you wish to choose a random format from a non-executable source or persistent storage (json etc.).
* This method is useful though if you wish to build a random string from a static, non-executable source (eg string coming from a user, stored in a database or a file).

*
* It checks the given string for placeholders and replace them by calling the specified faker method.
* E.g. the input `Hi, my name is {{name.firstName}}!`,
* will use the `faker.name.firstName()` method to resolve the placeholder.
* It is also possible to combine static text with placeholders,
Expand Down