bebar
TypeScript icon, indicating that this package has built-in type declarations

0.63.0 • Public • Published

Bebar

Coverage Badge Node.js CI pages-build-deployment

API documentation

What is it?

Bebar combines multiple powerfull tools so you can grab data somwhere, and merge it with a template to produce documents.

In a .bebar file, you indicate a few things:

  • Where your data is (a path, a webserver). it can be json, yaml, csv, xml, ...
  • A template file in a mustache format
  • Where to put the result for the merge between you data and your template

And with this you will be able to generate a new readable file thw way you want.

Additionnaly, you can also indicate:

  • Where to find partial mustache templates (so you can split and reuse your template parts)
  • Where to find helpers which are javascript functions to help you transform your data (to display human-readable dates, currency amounts, various conversions, ...)
  • Prettify options so your final output looks beter!

How to use Bebar

Install

npm install -g bebar

Run

bebar

Command line arguments

  • -f, --filename [optional] The filename of you bebar file(s). The path can include a wildcard. If ommited, will default to *.bebar.
  • -v, --verbosity [optional] Indicates the verbosity level to use. If ommited, will default to INFO. Possible values are INFO, WARN, ERROR and NONE.

A basic example

The data (schools.json)

[
  {
    "id": 1,
    "name": "Harvard University"
  },
  {
    "id": 2,
    "name": "Massachusetts Institute of Technology"
  },
  {
    "id": 3,
    "name": "Stanford University"
  },
]

The template (list_of_schools.mustache)

# List of schools
{{#each schools}}
{{school.id}}. {{school.name}}

{{/each}}

The bebar file (schools.bebar)

data:
  -
    file: ./schools.json
templates:
  -
    file: list_of_schools.mustache
    output: schools.md

The result (schools.md)

# List of schools
1. Harvard University
2. Massachusetts Institute of Technology
3. Stanford University

Installation

npm install bebar -g

Usage

Command

Options

How to create a bebar file

Your bebar file should is in yaml format. It is used to tell bebar where to find your data, your templates, where to generate files...

Loading data

You can get your data from anywhere with bebar (a csv, xml, json, yaml, ...).

Full explanations & examples here

Setup your template(s)

Your data will be 'merged' with a mustache template to produce an output result.

Full explanations & examples here

Setup helper functions

You can load javascript functions to help you format your data.

Full explanations & examples here

Setup partial functions

If your template file is too big, or you want to be able to resuse parts of templates, you can split your files using partials and call them from your template.

Full explanations & examples here

Credits

Dependencies

Dev dependencies

Package Sidebar

Install

npm i bebar

Weekly Downloads

0

Version

0.63.0

License

Apache

Unpacked Size

1.47 MB

Total Files

94

Last publish

Collaborators

  • yoann