Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bam.tech/parcel-plugin-handlebars-mock

Package Overview
Dependencies
Maintainers
12
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bam.tech/parcel-plugin-handlebars-mock - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

2

package.json
{
"name": "@bam.tech/parcel-plugin-handlebars-mock",
"version": "2.0.0",
"version": "2.0.1",
"description": "Parcel plugin to populate html during development.",

@@ -5,0 +5,0 @@ "main": "index.js",

# @bam.tech/parcel-plugin-handlebars-mock
Populate HTML file with mock data in development.
It also let you register helper methods for handlebars

@@ -11,2 +12,4 @@ ## Installation

### Mock data
- Create a `src/mock` directory.

@@ -17,3 +20,3 @@ - For each html file (named `foo.html` for example), create a `src/mock/foo.html.js` with the mock content:

module.exports = {
bar: "baz",
bar: 'baz',
};

@@ -23,1 +26,13 @@ ```

- 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;
});
```
const handlebars = require('handlebars');
const HTMLAsset = require('parcel-bundler/src/assets/HTMLAsset');
const path = require('path')
const path = require('path');
const MOCK_DIR = './src/mock';
const HELPER_DIR = './src/helper';
class HbsAsset extends HTMLAsset {
parse(code) {
require(path.join(__dirname, '../../../..', HELPER_DIR));
if (process.env.NODE_ENV === 'production') {
return super.parse(code)
return super.parse(code);
}

@@ -15,5 +18,5 @@

const mockData = require(path.join(__dirname, '../../../..', MOCK_DIR, this.basename))
const mockData = require(path.join(__dirname, '../../../..', MOCK_DIR, this.basename));
const html = template(mockData)
const html = template(mockData);

@@ -20,0 +23,0 @@ return super.parse(html);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc