# hbs-extract

> extracting json data from handlebar template

Latest version **0.1.0** (published 2015-10-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install hbs-extract
pnpm add hbs-extract
yarn add hbs-extract
bun add hbs-extract
```

Provides the command `hbs-extract`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2015-10-01 |
| First published | 2015-09-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| Author | chihsuan |
| Maintainers | chihsuan |
| Keywords | canner, handlebars, extract |

## Links

- npm: https://www.npmjs.com/package/hbs-extract
- Repository: https://github.com/canner/hbs-extract
- Issues: https://github.com/canner/hbs-extract/issues
- npm.io page: https://npm.io/package/hbs-extract

## Dependencies (7)

- [q](https://npm.io/package/q.md) ^1.0.1
- [q-io](https://npm.io/package/q-io.md) ^1.12.0
- [chalk](https://npm.io/package/chalk.md) ^1.0.0
- [lodash](https://npm.io/package/lodash.md) ^2.4.2
- [commander](https://npm.io/package/commander.md) ^2.5.0
- [handlebars](https://npm.io/package/handlebars.md) ^4.0.0
- [js-beautify](https://npm.io/package/js-beautify.md) ^1.5.4

## Recent versions

- 0.1.0 (latest) — 2015-10-01
- 0.0.8 — 2015-09-29
- 0.0.7 — 2015-09-25
- 0.0.6 — 2015-09-25
- 0.0.5 — 2015-09-15
- 0.0.4 — 2015-09-15
- 0.0.3 — 2015-09-11
- 0.0.2 — 2015-09-11
- 0.0.1 — 2015-09-11

## README

# hbs-extract

## Install

```
npm install -g hbs-extract
```

## Usage

```
  Usage: hbs-extract [options] <hbs_template, default value: "index.hbs">

  Options:

    -h, --help               output usage information
    -o, --output [filename]  output result to a json file.
    -V, --version            output the version number
```

## Example

```html
<html>
	<head>
		<title>
			{{title}}
		</title>
	</head>

	<body>
    {{body}}
    {{#each people}}
      <div>
        <h1>name:</h1>{{name}}
        <div>
          Works:
          <ul>
            {{#each work}}
              <li>
              {{content}}
              </li>
            {{/each}}
          </ul>
            {{mycar.title}}
        </div>
      </div>
     {{/each}}
     {{footer.content}}
	</body>
</html>
```

**Result**

```json
{
    "title": "",
    "body": "",
    "people": [{
        "name": "",
        "work": [{
            "content": ""
        }],
        "mycar": {
            "title": ""
        }
    }],
    "footer": {
        "content": ""
    }
}
```

## API

#### hbs_extract.fromFile(hbs_file)

-hbs_file: path to hbs file

return a promise 

``` javascript
hbs_extract.fromFile(hbs_file)
  .then(function(result) {
    // console.log(result)
  });
```

#### hbs_extract.raw(hbs_content)

-hbs_content: string

return data 

``` javascript
var data = hbs_extract.raw(hbs_str);

```

---
_Source: https://npm.io/package/hbs-extract · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
