预编译Jinja2模板为Python字节码
项目描述
预编译Jinja2模板为Python字节码。
用法
Jinja2预编译器附带一个名为jinja2precompiler的实用脚本。请在命令行提示符下输入jinja2precompiler --help以了解更多关于此工具的信息。
编译Jinja2模板
然后运行jinja2precompiler命令
$ jinja2precompiler templates Compiling into folder "templates" ... Compiled "templates/template.html" as tmpl_5f0fcb0ed56efa600c50d9f2870192327823c063.py ... Finished compiling templates
使用--pyc选项编译为Python字节码
$ jinja2precompiler --pyc templates Compiling into folder "templates" ... Compiled "templates/template.html" as tmpl_5f0fcb0ed56efa600c50d9f2870192327823c063.pyc ... Finished compiling templates
获取编译后的模块名称
使用--modulename选项将返回模块文件名
$ jinja2precompiler --modulename templates/template.html tmpl_41d3b4a4b71afe0c223778e57c23244caee1baec.py $ jinja2precompiler --modulename --pyc templates/template.html tmpl_41d3b4a4b71afe0c223778e57c23244caee1baec.pyc
您可以使用--base选项添加目录路径
$ jinja2precompiler --modulename --base=templates templates/template.html templates/tmpl_5f0fcb0ed56efa600c50d9f2870192327823c063.py
如果您指定了多个参数,将返回指定的模块文件名
$ jinja2precompiler --modulename a.html b.html c.html tmpl_25e7e8960b03ecb19189f36b8ef611389397c95c.py tmpl_83d0d31e29a7746a19536d616218a384f62d4694.py tmpl_45ecd51cee2d33904a8cd1af7c441dd3fc320870.py
使用Make
示例Makefile文件
templates_compiled.zip: $(wildcard templates/*.html) jinja2precompiler -c templates zip -FS -j templates_compiled.zip templates/*.pyc
仅编译更新的文件并将其存储到zip文件中。
安装
使用pip从PyPI安装
pip install jinja2precompiler
使用easy_install从PyPI安装
easy_install jinja2precompiler
从源代码安装
python setup.py install
依赖项
变更
0.2:支持遍历符号链接目录
许可
Jinja2预编译器根据BSD 3-Clause许可证的条款进行许可。
版权所有 2012 ENDOH takanao.
项目详情
关闭
jinja2-precompiler-0.2.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | e9ffe1b4414b4f86273f1f14da0d9a2155837044c434f7ca17642f7fd98da449 |
|
MD5 | 88e72825cfba21b8b2fa8d7a300b80b2 |
|
BLAKE2b-256 | 2ef248b9ca6af2f95a9de60a2eae05abc2d93d66516627fce58ad529a031c9a3 |