Grok源渲染器
megrok.rendersource的Python项目详细描述
Grok源渲染器
首先,让grok模板提供zope.app.render类。
structuredText:扩展名为“.rst”的模板文件
呈现完整的HTML页面,包括嵌入的样式表(默认) 或者使用可配置的外部样式表
安装
将“megrok.rendersource”添加到包“setup.py”中的“install\u requires”列表中。 再次运行buildout。 模板重新加载仅在开发人员模式下可用: 将“devmode on”添加到buildout.cfg中的“zope.conf=”行
配置
要配置模板使用的样式表,请添加方法“namespace” 到您的视图类:
class Overview(grok.View): def namespace(self): # compute the stylesheet path to the file inside the 'static' folder, # eg. 'grok.css' stylesheet=self.static['grok.css']() # enable absolut URL handling, disable embedding return {'settings_overrides': {'stylesheet': stylesheet, 'stylesheet_path': None, 'embed_stylesheet': 0, 'input_encoding': 'utf-8', 'output_encoding': 'utf-8', }}
其他与docutils相关的选项可以添加到“设置覆盖” 字典。cf grok_overview.txt获取有关命名空间方法的更多信息。
更改
0.5.1(2010-03-10)
- 添加了详细说明…
0.5(2010-03-10)
- 升级至grok 1.1rc1版本
- 将项目命名空间从d2m.rendersource更改为megrok.rendersource