Skip to main content

Yet another jinja2 cli command for static text generation

Project description

https://api.travis-ci.org/moremoban/moban.svg?branch=master https://codecov.io/gh/moremoban/moban/branch/master/graph/badge.svg https://readthedocs.org/projects/moban/badge/?version=latest https://img.shields.io/gitter/room/gitterHQ/gitter.svg
Author:

C.W.

Issues:

http://github.com/moremoban/moban/issues

License:

MIT

moban brings the high performance template engine (JINJA2) for web into static text generation. It is used in pyexcel project to keep documentation consistent across the documentations of individual libraries.

Installation

You can install it via pip:

$ pip install moban

or clone it and install it:

$ git clone http://github.com/moremoban/moban.git
$ cd moban
$ python setup.py install

Quick start

Here is a simple example:

$ moban -c data.yml -t my.template
$ cat moban.output

Given data.yml as:

hello: world

and my.template as:

{{hello}}

moban.output will contain:

world

the tutorial has more use cases.

Usage

usage: moban [-h] [-cd CONFIGURATION_DIR] [-c CONFIGURATION]
             [-td [TEMPLATE_DIR [TEMPLATE_DIR ...]]] [-t TEMPLATE] [-o OUTPUT]
             [-f] [-m MOBANFILE]

Yet another jinja2 cli command for static text generation

optional arguments:
  -h, --help            show this help message and exit
  -cd CONFIGURATION_DIR, --configuration_dir CONFIGURATION_DIR
                        the directory for configuration file lookup
  -c CONFIGURATION, --configuration CONFIGURATION
                        the dictionary file
  -td [TEMPLATE_DIR [TEMPLATE_DIR ...]], --template_dir [TEMPLATE_DIR [TEMPLATE_DIR ...]]
                        the directories for template file lookup
  -t TEMPLATE, --template TEMPLATE
                        the template file
  -o OUTPUT, --output OUTPUT
                        the output file
  --template_type TEMPLATE_TYPE
                        the template type, default is jinja2
  -f                    force moban to template all files despite of
                        .moban.hashes
  -m MOBANFILE, --mobanfile MOBANFILE
                        custom moban file

exit codes

  • 0 : no changes

  • 1 : has changes

  • 2 : error occured

Built-in Filters

split_length

It breaks down the given string into a fixed length paragraph. Here is the syntax:

{% for line in your_string | split_length(your_line_with) %}
{{line}}
{% endfor %}

It is used to keep changelog formatted in CHANGELOG.rst.jjs in pypi-mobans project

github_expand

It expands simple hashtags into github issues. Here is the syntax:

{{ your_github_string | github_expand }}

It makes it easy to mention github reference in change log in all projects. Here is the place it is applied: CHANGELOG.rst.jjs in pypi-mobans project

Here is Grammar in the changelog.yml:

=============== ==============================
Syntax          Meaning
=============== ==============================
`#1`            moban issues 1
`PR#1`          moban pull request 1
`pyexcel#1`     other project issues 1
`pyexcel#PR#1`  other project pulll request 1
=============== ==============================

More details can be found in moban’s changelog.yml

repr

Returns a single quoted string in the templated file

Built-in Tests

exists

Test if a file exists or not

Contributors

In alphabetical order:

Change log

0.3.5 - 10-12-2018

Updated

  1. #37: moban will report line number where the value is empty and the name of mobanfile. Switch from pyyaml to ruamel.yaml.

0.3.4.1 - 28-11-2018

Updated

  1. #137: missing contributors.rst file

0.3.4 - 18-11-2018

Added

  1. global variables to store the target and template file names in the jinja2 engine

  2. moban-handlebars is tested to work well with this version and above

Updated

  1. Template engine interface has been clarified and documented

0.3.3 - 05-11-2018

Added

  1. alternative and expanded syntax for requires, so as to accomendate github submodule recursive

0.3.2 - 04-11-2018

Added

  1. requires shall support configuration dirs. In other words, configuration file could be stored in python package or git repository.

0.3.1 - 02-11-2018

Added

  1. #97: requires will clone a repo if given. Note: only github, gitlab, bitbucket for now

0.3.0 - 27-18-2018

Added

  1. #89: Install pypi-hosted mobans through requires syntax

Updated

  1. #96: Fix for FileNotFoundError for plugins

  2. various documentation updates

Removed

  1. #88: removed python 2.6 support

  2. removed python 3.3 support

0.2.4 - 14-07-2018

Added

  1. #32: option 1 copy a directory without its subdirectories.

  2. #30: command line template option is ignore when a moban file is present

0.2.3 - 10-07-2018

Added

  1. #76: running moban as a module from python command

  2. #32: copy a directory recusively

  3. #33: template all files in a directory

0.2.2 - 16-06-2018

Added

  1. #31: create directory if missing during copying

Updated

  1. #28: if a template has been copied once before, it is skipped in the next moban call

0.2.1 - 13-06-2018

Updated

  1. templates using the same template engine will be templated as a group

  2. update lml dependency to 0.0.3

0.2.0 - 11-06-2018

Added

  1. #18: file exists test

  2. #23: custom jinja plugins

  3. #26: repr filter

  4. #47: allow the expansion of template engine

  5. #58: allow template type per template

Updated

  1. #34: fix plural message if single file is processed

0.1.4 - 29-May-2018

Updated

  1. #21: targets become optional

  2. #19: transfer symlink’s target file’s file permission under unix/linux systems

  3. #16: introduce copy key word in mobanfile

0.1.3 - 12-Mar-2018

Updated

  1. handle unicode on python 2

0.1.2 - 10-Jan-2018

Added

  1. #13: strip off new lines in the templated file

0.1.1 - 08-Jan-2018

Added

  1. the ability to present a long text as multi-line paragraph with a custom upper limit

  2. speical filter expand github references: pull request and issues

  3. #15: fix templating syntax to enable python 2.6

0.1.0 - 19-Dec-2017

Added

  1. #14, provide shell exit code

0.0.9 - 24-Nov-2017

Added

  1. #11, recognize .moban.yaml as well as .moban.yml.

  2. #9, preserve file permissions of the source template.

  3. -m option is added to allow you to specify a custom moban file. kinda related to issue 11.

Updated

  1. use explicit version name: moban_file_spec_version so that version can be used by users. #10 Please note: moban_file_spec_version is reserved for future file spec upgrade. For now, all files are assumed to be ‘1.0’. When there comes a new version i.e. 2.0, new moban file based on 2.0 will have to include ‘moban_file_spec_version: 2.0’

0.0.8 - 18-Nov-2017

Added

  1. #8, verify the existence of custom template and configuration directories. default .moban.td, .moban.cd are ignored if they do not exist.

Updated

  1. Colorize error messages and processing messages. crayons become a dependency.

0.0.7 - 19-Jul-2017

Added

  1. Bring the visibility of environment variable into jinja2 templating process: #7

0.0.6 - 16-Jun-2017

Added

  1. added ‘-f’ flag to force moban to template all files despite of .moban.hashes

Updated

  1. moban will not template target file in the situation where the changes occured in target file than in the source: the template file + the data configuration after moban has been applied. This new release will remove the change during mobanization process.

0.0.5 - 17-Mar-2017

Added

  1. Create a default hash store when processing a moban file. It will save unnecessary file write to the disc if the rendered content is not changed.

  2. Added summary reports

0.0.4 - 11-May-2016

Updated

  1. Bug fix #5, should detect duplicated targets in .moban.yml file.

0.0.3 - 09-May-2016

Updated

  1. Bug fix #4, keep trailing new lines

0.0.2 - 27-Apr-2016

Updated

  1. Bug fix #1, failed to save utf-8 characters

0.0.1 - 23-Mar-2016

Added

  1. Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

moban-0.3.5.tar.gz (24.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

moban-0.3.5-py2.py3-none-any.whl (24.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file moban-0.3.5.tar.gz.

File metadata

  • Download URL: moban-0.3.5.tar.gz
  • Upload date:
  • Size: 24.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.6

File hashes

Hashes for moban-0.3.5.tar.gz
Algorithm Hash digest
SHA256 201c3fd2b6b0f6d6b9e2aed40cd54906c42fc9b1c9011455222804c02f2e5ab7
MD5 b8ccdcb875f29087ef2fb011c7b3ec8d
BLAKE2b-256 ded9571b5918871ef6866ea3e963a96844f153424f31614b9a69ee82b5f3267e

See more details on using hashes here.

File details

Details for the file moban-0.3.5-py2.py3-none-any.whl.

File metadata

  • Download URL: moban-0.3.5-py2.py3-none-any.whl
  • Upload date:
  • Size: 24.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.6

File hashes

Hashes for moban-0.3.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a1174b29209397c1c5b97a94556ab3d12c29a8c4aaa98be83175c0fcff6e439a
MD5 0d21feedd024b1d307b9bf55a3bead66
BLAKE2b-256 8e3017a0a6cf723118fb2f3f347adccf562631f05648f007007e99848441bd57

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page