Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .moban.cd/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
name: moban
organisation: moremoban
releases:
- changes:
- action: Added
details:
- "global variables to store the target and template file names in the jinja2 engine"
- "moban-handlebars is tested to work well with this version and above"
- action: Updated
details:
- Template engine interface has been clarified and documented
date: 14-11-2018
version: 0.3.4
- changes:
- action: Added
details:
Expand Down
6 changes: 3 additions & 3 deletions .moban.cd/moban.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ organisation: moremoban
author: C. W.
contact: wangc_2011@hotmail.com
license: MIT
version: 0.3.3
current_version: 0.3.3
version: 0.3.4
current_version: 0.3.4
release: 0.3.3
branch: master
command_line_interface: "moban"
Expand All @@ -17,7 +17,7 @@ keywords:
dependencies:
- pyyaml>=3.11
- jinja2>=2.7.1
- lml==0.0.4
- lml>=0.0.7
- crayons
description: Yet another jinja2 cli command for static text generation
scm_host: github.com
15 changes: 15 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
Change log
================================================================================

0.3.4 - 14-11-2018
--------------------------------------------------------------------------------

Added
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#. global variables to store the target and template file names in the jinja2
engine
#. moban-handlebars is tested to work well with this version and above

Updated
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#. Template engine interface has been clarified and documented

0.3.3 - 05-11-2018
--------------------------------------------------------------------------------

Expand Down
7 changes: 4 additions & 3 deletions CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Contributors

In alphabetical order:

`John Vandenberg <https://github.com/jayvdb>`_
`PRAJWAL M <https://github.com/PrajwalM2212>`_
`SerekKiri <https://github.com/SerekKiri>`_
* `Charlie Liu <https://github.com/CLiu13>`_
* `John Vandenberg <https://github.com/jayvdb>`_
* `PRAJWAL M <https://github.com/PrajwalM2212>`_
* `SerekKiri <https://github.com/SerekKiri>`_
2 changes: 2 additions & 0 deletions docs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This section covers the use cases for moban. Please check them out individually.
#. `Pass a folder full of templates`_
#. `Use pypi package as a moban dependency`_
#. `Use git repository as a moban dependency`_
#. `Use handlebars template with moban`_

.. _Jinja2 command line: level-1-jinja2-cli
.. _Template inheritance: level-2-template-inheritance
Expand All @@ -24,3 +25,4 @@ This section covers the use cases for moban. Please check them out individually.
.. _Pass a folder full of templates: level-8-pass-a-folder-full-of-templates
.. _Use pypi package as a moban dependency: level-9-moban-dependency-as-pypi-package
.. _Use git repository as a moban dependency: level-10-moban-dependency-as-git-repo
.. _Use handlebars template with moban: level-11-use-handlebars
29 changes: 21 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# The short X.Y version
version = u'0.3.3'
# The full version, including alpha/beta/rc tags
release = u'0.3.3'
release = u'0.3.4'


# -- General configuration ---------------------------------------------------
Expand All @@ -42,12 +42,7 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.viewcode',
]
extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'sphinx.ext.viewcode',]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand All @@ -74,7 +69,7 @@
exclude_patterns = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = None


# -- Options for HTML output -------------------------------------------------
Expand Down Expand Up @@ -162,6 +157,24 @@
'Miscellaneous'),
]


# -- Options for Epub output -------------------------------------------------

# Bibliographic Dublin Core info.
epub_title = project

# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''

# A unique identification for the text.
#
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']

# -- Extension configuration -------------------------------------------------
# -- Options for intersphinx extension ---------------------------------------

Expand Down
24 changes: 23 additions & 1 deletion docs/extension.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,29 @@ template engines, such as marko, haml can be plugged into moban seamless.
In order plugin other template engines, it is to write a lml plugin. The following
is an example starting point for any template engine.

.. literalinclude:: ../tests/moban-mako/moban_mako/__init__.py
.. code::

@PluginInfo(
constants.TEMPLATE_ENGINE_EXTENSION, tags=["file", "extensions", "for", "your", "template"]
)
class Engine(object):
def __init__(self, template_dirs):
"""
A list template directories will be given to your engine class
"""

def get_template(self, template_file):
"""
Given a relative path to your template file, please return a templatable thing that does
the templating function in next function below
"""

def apply_template(self, template, data, output):
"""
Given the template object from `get_template` function, and data as python dictionary,
and output as intended output file, please return "utf-8" encoded string.
"""


After you will have finished the engine plugin, you can either place it in `plugin_dir`
in order to get it loaded, or make an installable python package. In the latter case,
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ examples folder.
level-8-pass-a-folder-full-of-templates/README.rst
level-9-moban-dependency-as-pypi-package/README.rst
level-10-moban-dependency-as-git-repo/README.rst
level-11-use-handlebars/README.rst

In pratice, the following use cases were found interesting to go along with.

Expand Down
2 changes: 2 additions & 0 deletions docs/level-11-use-handlebars/.moban.cd/data.base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nihao: shijie
hello: shijie
5 changes: 5 additions & 0 deletions docs/level-11-use-handlebars/.moban.td/base.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

{{hello}}

{{nihao}}

3 changes: 3 additions & 0 deletions docs/level-11-use-handlebars/.moban.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
targets:
- a.output: a.template.handlebars
- b.output: base.hbs
30 changes: 30 additions & 0 deletions docs/level-11-use-handlebars/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Level 11: use handlebars
================================================================================

moban is extensible via lml. Charlie Liu through Google Code-in 2018 has
kindly contributed moban-handlebars plugin.


Evaluation
--------------------------------------------------------------------------------

Please go to `docs/level-11-use-handlebars` directory. You will have to::

$ pip install moban-handlebars


Here is the `.moban.yml`, which replaces `jj2` with handlebars files in level 4::

targets:
- a.output: a.template.handlebars
- b.output: base.hbs


where `targets` should lead an array of dictionaries, `requires` installs
moban-handlebars extension. You can provide file suffixes: ".handlebars"
or ".hbs" to your handlebars template.

Here is how to launch it
.. code-block:: bash

moban
1 change: 1 addition & 0 deletions docs/level-11-use-handlebars/a.template.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{no-inheritance}}
4 changes: 4 additions & 0 deletions docs/level-11-use-handlebars/b.output
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

world

shijie
3 changes: 3 additions & 0 deletions docs/level-11-use-handlebars/data.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
overrides: data.base.yaml
hello: world
no-inheritance: handlebars does not support inheritance
2 changes: 1 addition & 1 deletion docs/level-4-single-command/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Evaluation
Please go to `docs/level-4-single-command` directory.


Here is the `.moban.yml`, whihc replaces the command in level 3::
Here is the `.moban.yml`, which replaces the command in level 3::

targets:
- a.output: a.template
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
import base64

from moban.extensions import JinjaFilter
from moban.jinja2.extensions import JinjaFilter


@JinjaFilter()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from moban.extensions import jinja_global
from moban.jinja2.extensions import jinja_global

jinja_global('global', dict(hello='world'))
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from moban.extensions import JinjaTest
from moban.jinja2.extensions import JinjaTest


@JinjaTest()
Expand Down
2 changes: 1 addition & 1 deletion moban/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "0.3.3"
__version__ = "0.3.4"
__author__ = "C. W."
20 changes: 0 additions & 20 deletions moban/base_engine.py
Original file line number Diff line number Diff line change
@@ -1,20 +0,0 @@
import moban.reporter as reporter


class BaseEngine(object):
def __init__(self):
self.templated_count = 0
self.file_count = 0

def report(self):
if self.templated_count == 0:
reporter.report_no_action()
elif self.templated_count == self.file_count:
reporter.report_full_run(self.file_count)
else:
reporter.report_partial_run(
self.templated_count, self.file_count
)

def number_of_templated_files(self):
return self.templated_count
Loading