https://github.com/bamlab/parcel-plugin-handlebars-mock
https://github.com/bamlab/parcel-plugin-handlebars-mock
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/bamlab/parcel-plugin-handlebars-mock
- Owner: bamlab
- Created: 2021-02-24T10:13:10.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-06-01T15:59:17.000Z (about 5 years ago)
- Last Synced: 2024-04-15T00:00:05.746Z (about 2 years ago)
- Language: JavaScript
- Homepage:
- Size: 85.9 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @bam.tech/parcel-plugin-handlebars-mock
Populate HTML file with mock data in development.
It also let you register helper methods for handlebars
## Installation
`yarn add @bam.tech/parcel-plugin-handlebars-mock`
## Usage
### Mock data
- Create a `src/mock` directory.
- For each html file (named `foo.html` for example), create a `src/mock/foo.html.js` with the mock content:
```js
module.exports = {
bar: 'baz',
};
```
- If `NODE_ENV` is `production`, then the plugin is not applied.
### Register helper methods
- create a `src/helper` directory with an `index.js` that register some templates
```js
const Handlebars = require('handlebars');
Handlebars.registerHelper('isArrayBig', (array) => {
return array.length > 3;
});
```