跳转到主要内容

极其简洁的文本文件模板引擎

项目描述

一个小型模板引擎,通过字典值替换变量

cat file.txt
"This is a {{variable}} in a {{string}}"

from coima import Template
t = Template({'variable':'word', 'string':'sentence'}, 'file.txt')

t.render()

u"This is a word in a sentence"

语法

不允许Python或代码块,这是一个基本的模板引擎。

变量应为一个单词或由下划线连接的两个单词。这些是有效变量

{{variable}} {{variable_one}}

无效变量将被保留原样,并留在最终的渲染模板中。

由以下支持

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