壁画模板系统集成
fresco-template的Python项目详细描述
Jinja2的示例用法:
from fresco import FrescoApp from fresco_template import Jinja2 from jinja2 import PackageLoader app = FrescoApp() jinja2 = Jinja2(loader=PackageLoader('mypackage', 'template/dir')) jinja2.init_app(app) @jinja2.contextprocessor def default_context(): # Return a dictionary of variables always to be included in the # template context. # # NB the fresco context object and urlfor function are already included # in the template context by default. return {} @jinja2.render('page.html') def myview(): return {'var': 'value'}
变色龙的例子相同:
from fresco import FrescoApp from fresco_template import Chameleon from chameleon import PageTemplateLoader app = FrescoApp() loader = PageTemplateLoader(['template/dir'], auto_reload=True) chameleon = Chameleon(loader) chameleon.init_app(app) @chameleon.contextprocessor def default_context(): # Return a dictionary of variables always to be included in the # template context. # # NB the fresco context object and urlfor function are already included # in the template context by default. return {} @chameleon.render('page.html') def myview(): return {'var': 'value'}
0.3.1(2016-11-29发布)
- 增加了对 Piglet templating engine。
0.3.0(发布日期:2015-09-25)
增加了对kajiki的支持
environment变量的名称已更改为loader,并且 不再直接在templateenvironment对象上可用,但是 通过plugin属性。例如:
from jinja2 import Environment, FileSystemLoader from fresco_template import Jinja2 # Old style - BROKEN in 0.3 release: j2 = Jinja2(environment=Environment(FileSystemLoader('templates'))) j2.environment.install_gettext_translations(my_translation_module) # New style: j2 = Jinja2(Environment(autoescape=True, FileSystemLoader('templates'))) j2.plugin.loader.install_gettext_translations(my_translation_module)
任何自定义插件都需要重写。指任何违约 例如插件。
0.2.1
- TemplateContent类现在调用 实例化。这确保了上下文处理器总是在 发送响应头。
0.2
初始版本
0.1
(未发行版本)