moban-handlebars 0.0.5
Provide handlebars templating capability to moban.
License: MIT
Keywords: python

================================================================================
moban-handlebars
================================================================================

.. image:: https://api.travis-ci.org/moremoban/moban-handlebars.svg
   :target: http://travis-ci.org/moremoban/moban-handlebars

.. image:: https://codecov.io/github/moremoban/moban-handlebars/coverage.png
   :target: https://codecov.io/github/moremoban/moban-handlebars
.. image:: https://badge.fury.io/py/moban-handlebars.svg
   :target: https://pypi.org/project/moban-handlebars

.. image:: https://pepy.tech/badge/moban-handlebars/month
   :target: https://pepy.tech/project/moban-handlebars/month

.. image:: https://img.shields.io/github/stars/moremoban/moban-handlebars.svg?style=social&maxAge=3600&label=Star
    :target: https://github.com/moremoban/moban-handlebars/stargazers



Introduction
==============

With `pybars3 <https://github.com/wbond/pybars3>`_, this library allow moban users to
have handlebars template in their next documentation endeavour.

Quick start
============


.. code-block:: bash

   $ moban "<p>{{firstname}} {{lastname}}</p>" --template-type handlebars -d firstname=hello lastname=world

Nested input objects
---------------------

Given a data.json file with the following content

.. code-block::

    {
      "person": {
        "firstname": "Yehuda",
        "lastname": "Katz",
      },
    }


.. code-block:: bash


   $ moban --template-type handlebars -c data.json  "{{person.firstname}} {{person.lastname}}"
   Handlebars-ing <p>{{first... to moban.output
   Handlebarsed 1 file.
   $ cat moban.output
   Yehuda Katz

For `handlebars.js` users, yes, the example was copied from handlebarjs.com. The
aim is to show off what we can do.

Let's continue with a bit more fancy feature:



.. code-block:: bash

   $ moban --template-type handlebars -c data.json "{{#with person}}{{firstname}} {{lastname}} {{/with}}"


Moban's way of `pybar3 usage <https://github.com/wbond/pybars3#usage>`_:

Let's save the following file a `script.py` under `helper_and_partial` folder:

.. code-block:: python

   from moban_handlebars.api import Helper, register_partial

   register_partial('header', '<h1>People</h1>')


   @Helper('list')
   def _list(this, options, items):
       result = [u'<ul>']
       for thing in items:
           result.append(u'<li>')
           result.extend(options['fn'](thing))
           result.append(u'</li>')
       result.append(u'</ul>')
       return result

And given `data.json` reads as the following:

.. code-block::

   {
       "people":[
           {"name": "Bill", "age": 100},
           {"name": "Bob", "age": 90},
           {"name": "Mark", "age": 25}
       ]
   }

Let's invoke handlebar template:


.. code-block:: bash

   $ moban --template-type hbs -pd helper_and_partial -c data.json "{{>header}}{{#list people}}{{name}} {{age}}{{/list}}"
   Handlebars-ing {{>header}... to moban.output
   Handlebarsed 1 file.
   $ cat moban.output
   <h1>People</h1><ul><li>Bill 100</li><li>Bob 90</li><li>Mark 25</li></ul>



Installation
================================================================================


You can install moban-handlebars via pip:

.. code-block:: bash

    $ pip install moban-handlebars


or clone it and install it:

.. code-block:: bash

    $ git clone https://github.com/moremoban/moban-handlebars.git
    $ cd moban-handlebars
    $ python setup.py install

Author
================================================================================

Charlie Liu

Contributors
================================================================================

In alphabetical order:

* `C. W. <https://github.com/chfw>`_
* `John Vandenberg <https://github.com/jayvdb>`_
* `PRAJWAL M <https://github.com/PrajwalM2212>`_

Change log
================================================================================

0.0.5 - 07.06.2020
--------------------------------------------------------------------------------

**Updated**

#. Name the moban actions when this template is used
#. `#12 <https://github.com/moremoban/moban-handlebars/issues/12>`_: provide
   apis for end user to use their own block helper and partials

0.0.4 - 14.10.2019
--------------------------------------------------------------------------------

**Updated**

#. `#10 <https://github.com/moremoban/moban-handlebars/issues/10>`_: support
   moban v6.5

0.0.3 - 10.09.2019
--------------------------------------------------------------------------------

**Updated**

#. `#7 <https://github.com/moremoban/moban-handlebars/issues/7>`_: support moban
   v4.1
#. `#9 <https://github.com/moremoban/moban-handlebars/issues/9>`_: support moban
   v6

0.0.2 - 22-01-2019
--------------------------------------------------------------------------------

**Updated**

#. `#1 <https://github.com/moremoban/moban-handlebars/issues/1>`_: support moban
   v0.3.8
#. `#2 <https://github.com/moremoban/moban-handlebars/issues/2>`_: add license
   file
#. `#3 <https://github.com/moremoban/moban-handlebars/issues/3>`_: support moban
   v0.3.9

0.0.1 - 18-11-2018
--------------------------------------------------------------------------------

**First release**

#. render .hbr .handlebars files for moban