0.1.0 • Published 10 years ago

hbs-extract v0.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

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);
0.1.0

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago