一个非固执己见的模板抽象层

TemplateAlchem的Python项目详细描述


tl;dr

安装:

$ pip install templatealchemy
使用:

importtemplatealchemyasta# create a top-level template managerroot=ta.Manager(source='pkg:mypackagename:lib/templates',renderer='mako',)# load the sub-template 'foo'foo=root.getTemplate('foo')# render the 'text' version with some parameters; the# actual template is then in 'mypackagename:lib/templates/foo.text'params=dict(value='bar',zig='zog')text=foo.render('text',params)# get meta information about the templateif'attachments'infoo.meta:forattachmentinfoo.meta.attachments:# ... do something with each attachment# supported formats are stored in meta.formatsassert(foo.meta.formats==['text','html'])

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
正则表达式Java使用关键字拆分字符串   Neo4j Java API模式索引范围查找?   java访问JButton[]   java如何混淆tomcat日志文件中的请求属性   apache运行CGI Java程序   java从一个Eclipse插件开始,我如何通过编程使Eclipse编辑某个文件?   从php中的SQL数据库到Java中的多个值作为单独的变量   java如何在多个osgi捆绑包之间共享资源   datetime Java time,无法从历元秒解析年份   java无法在安卓应用程序中使用morpho指纹扫描仪设备捕获指纹   java使用groovy/ratpack发送电子邮件   javascript在jsp页面中添加验证,但在控制台中仍然显示一些错误   java如何修复com。mysql。jdbc。DocsConnectionPropsHelper   java AlertDialog dispatchTouchEvent