GitXplorerGitXplorer
m

jinja2-precompiler

public
16 stars
2 forks
0 issues

Commits

List of commits on branch master.
Unverified
88ae4896b4b432c09592bdbc23847eb70f2d9e74

fix classifiers

mmichilu committed 11 years ago
Unverified
a63888a050c67dce6e94b09c8fd49145bfe2f270

update supports version of Python

mmichilu committed 11 years ago
Unverified
b6551cb95ad00ce8460880aceb0be83a32486728

bump up to 2.0 [skip ci]

mmichilu committed 11 years ago
Unverified
f278dc7830d996c7e00d491d4520325fa7bb5d59

refactor

mmichilu committed 11 years ago
Unverified
8ad9cdb43ec138bfc430c33f7dc29aa2e221dc2e

fix dir name without "/"(os.path.sep)

mmichilu committed 11 years ago
Unverified
ccefe8510a6ff2f2c3f6f200a1a012b46fa4ae5f

add test assets

mmichilu committed 11 years ago

README

The README file for this repository.

Jinja2 pre-compiler |Build Status|_

Pre-compile Jinja2 templates to Python byte code.

.. |Build Status| image:: https://travis-ci.org/MiCHiLU/jinja2-precompiler.png?branch=master .. _Build Status: http://travis-ci.org/MiCHiLU/jinja2-precompiler

Usage

Jinja2 pre-compiler comes with a utility script called jinja2precompiler. Please type jinja2precompiler --help at the shell prompt to know more about this tool.

Compiling the Jinja2 template


Then run ``jinja2precompiler`` command::

  $ jinja2precompiler templates
  Compiling into folder "templates"
  ...
  Compiled "templates/template.html" as tmpl_5f0fcb0ed56efa600c50d9f2870192327823c063.py
  ...
  Finished compiling templates

Will compiling to Python byte code with ``--pyc`` option::

  $ jinja2precompiler --pyc templates
  Compiling into folder "templates"
  ...
  Compiled "templates/template.html" as tmpl_5f0fcb0ed56efa600c50d9f2870192327823c063.pyc
  ...
  Finished compiling templates

Get the compiled module name
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Will return a module file name with ``--modulename`` option::

  $ jinja2precompiler --modulename templates/template.html
  tmpl_41d3b4a4b71afe0c223778e57c23244caee1baec.py

  $ jinja2precompiler --modulename --pyc templates/template.html
  tmpl_41d3b4a4b71afe0c223778e57c23244caee1baec.pyc

And you can prepend directory path with ``--base`` option::

  $ jinja2precompiler --modulename --base=templates templates/template.html
  templates/tmpl_5f0fcb0ed56efa600c50d9f2870192327823c063.py

Will return module file names you specify the argument more than one::

  $ jinja2precompiler --modulename a.html b.html c.html
  tmpl_25e7e8960b03ecb19189f36b8ef611389397c95c.py tmpl_83d0d31e29a7746a19536d616218a384f62d4694.py tmpl_45ecd51cee2d33904a8cd1af7c441dd3fc320870.py

With Make
~~~~~~~~~

An example ``Makefile`` file::

  templates_compiled.zip: $(wildcard templates/*.html)
  	jinja2precompiler -c templates
  	zip -FS -j templates_compiled.zip templates/*.pyc

Will compiling only updated files and storing into the zip file.


Installation
------------
Installing from PyPI using ``pip``::

    pip install jinja2precompiler

Installing from PyPI using ``easy_install``::

    easy_install jinja2precompiler

Installing from source::

    python setup.py install


Dependencies
------------
1. Jinja2_


Changes
-------

0.2: supports walking symlink directories


Licensing
---------
Jinja2 pre-compiler is licensed under the terms of the `BSD 3-Clause`_.

Copyright 2012 ENDOH takanao.

Project `source code`_ is available at Github. Please report bugs and file
enhancement requests at the `issue tracker`_.


.. links:
.. _Jinja2: http://jinja.pocoo.org/
.. _BSD 3-Clause: http://opensource.org/licenses/BSD-3-Clause
.. _issue tracker: http://github.com/MiCHiLU/jinja2-precompiler/issues
.. _source code: http://github.com/MiCHiLU/jinja2-precompiler