跳转到主要内容

Jinja2文件生成器

项目描述

金盏花从Jinja2模板文件生成文件。

用法

假设有一个变量文件mock_vars.py

VARS = {
    "test_var": "vars_file_test_value"
}

和一个模板文件:mock.template

I'M A MOCK TEMPLATE AND MY VAR IS: {{ test_var }}
from jingen.jingen import Jingen

template_file = "mock.template"
vars_source = "tests/resources/mock_vars.py"  # alternatively, can be a dict
output_file = "tests/resources/manual_test_result.file"
templates_dir = "tests/resources/"
make_file = True
verbose = True

i = Jingen(
    template_file=template_file,
    vars_source=vars_source,
    output_file=output_file,
    templates_dir=templates_dir,
    make_file=make_file,
    verbose=verbose)
output = i.generate()

print output
...
I'M A MOCK TEMPLATE AND MY VAR IS: vars_file_test_value

输出将是

### DEBUG - generating template from tests/resources//mock.template
### DEBUG - creating file: tests/resources/manual_test_result.file with content:
I'M A MOCK TEMPLATE AND MY VAR IS: vars_file_test_value

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪一个,请了解更多关于 安装包 的信息。

源分布

jingen-0.1.0.tar.gz (3.5 kB 查看散列值)

上传时间

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面