hbs-extract

0.1.0 • Public • Published

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>
    <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

{
    "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

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

hbs_extract.raw(hbs_content)

-hbs_content: string

return data

var data = hbs_extract.raw(hbs_str);
 

Dependents (1)

Package Sidebar

Install

npm i hbs-extract

Weekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • chihsuan