Skip to content

better-owlet/handlebars-variables-extract

Repository files navigation

Extract variables from handlebars

Usage

npm install handlebars-variables-extract
import extract from 'handlebars-variables-extract';
extract(`{{template}}`);

CDN

<script src="https://unpkg.com/[email protected]/dist/handlebars-variables-extract.umd.js"></script>

input

<p>{{firstname}} {{lastname}}</p>

output like JSON schema https://json-schema.org/

{
  "type": "object",
  "properties": {
    "firstname": {
      "type": "any"
    },
    "lastname": {
      "type": "any"
    }
  }
}

DEMO

Contributing

NPM scripts

  • npm t: Run test suite
  • npm start: Run npm run build in watch mode
  • npm run test:watch: Run test suite in interactive watch mode
  • npm run test:prod: Run linting and generate coverage
  • npm run build: Generate bundles and typings, create docs
  • npm run lint: Lints code
  • npm run commit: Commit using conventional commit style (husky will tell you to use it if you haven't 😉)

Excluding peerDependencies

On library development, one might want to set some peer dependencies, and thus remove those from the final bundle. You can see in Rollup docs how to do that.

Good news: the setup is here for you, you must only include the dependency name in external property within rollup.config.js. For example, if you want to exclude lodash, just write there external: ['lodash'].

This project refer to barhandles.

Contributions of any kind are welcome!