1.0.2 • Published 7 years ago

posthtml-faker v1.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

PostHTML-Faker

Tests

PostHTML-Faker is a plugin for PostHTML that let you use Faker.js features to generate fake data in your HTML documents.

Usage

Fake data must be delimited by the custom <fake> and </fake> tags. Within those tags a generator method is used for combining the Faker.js API methods using a mustache formatted string.

<fake>Hello {{name.firstName}}!</fake>

Within the <fake> tags, any mustache formatted strings will be interpolated.

<fake>{{name.firstName}} - {{name.lastName}}</fake>

Mustache formatted strings can be defined anywhere within the <fake> and </fake> tags.

<fake>
  <img src="{{image.avatar}}">
  <a href="#">{{name.firstName}}-{{name.lastName}}</a>
</fake>

Mustache Formatted Strings Validation

All function arguments within a mustache formatted strings must be defined as valid JSON data types (e.g., strings and object keys must be written in double quotes).

<p>
  <fake>{{lorem.paragraphs(3, "</p><p>")}}</fake>
</p>

JSON data types can be one of the following types:

  • The null literal.
  • A boolean literal.
  • A number literal, integer or decimal.
  • A double quoted string literal.
  • An array literal as [ value ... ].
  • A JSON object literal as { "key": value ... }.

Install

Add PostHTML and PostHTML-Faker to your build tool:

npm install posthtml posthtml-faker --save-dev

Enable this plugin as a standard PostHTML plugin:

posthtml([
  require("posthtml-faker")({
    /* options */
  })
]).process(...);

Options

NameTypeDefaultDescription
localestring'en'The locale for Faker.js.

License

This PostHTML plugin is MIT Licensed.

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago