编译器
jj2c的Python项目详细描述
版本号:0.1.3作者:汤唯
概述
Jinja2编译器
安装/使用
要安装,请使用pip:
$ pip install jj2c
使用它:
从文件夹呈现到文件夹: jj2c template_folder/ -V 'a: AAA' 'b: BBB' -o output_folder/
从zip呈现到文件夹: jj2c template.zip -V 'a: AAA' 'b: BBB' -o output_folder/
从zip渲染到zip: jj2c template.zip -V 'a: AAA' 'b: BBB' -o template.zip
呈现到stdout:jj2c template-file-V 'a: AAA' 'b: BBB'
或者克隆回购协议:
$ git clone https://github.com/tly1980/jj2c.git $ python setup.py install
使用Jinja2扩展名
假设您有一个use_do.tpl包含以下内容:
{%- set a = [] -%} {%- do a.append(1) -%} {%- do a.append(2) -%} {%- do a.append(name) -%} {{ a }}
为了正确地呈现这些内容,您需要 jinja2.ext.do扩展名。
使用-e或--extensions标记指定扩展名。你呢 可以指定多个。
jj2c tests/fixtures/use_do.tpl -V 'name: jack' -e jinja2.ext.do jinja2.ext.i18n
输出为:
Using extensions: ['jinja2.ext.do', 'jinja2.ext.i18n'] Compiling... file to stdout src: tests/fixtures/use_do.tpl dest:- [1, 2, 'jack']
贡献
待定
示例
待定