本文整理汇总了Python中simpletemplate.SimpleTemplate.render方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleTemplate.render方法的具体用法?Python SimpleTemplate.render怎么用?Python SimpleTemplate.render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simpletemplate.SimpleTemplate
的用法示例。
在下文中一共展示了SimpleTemplate.render方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_form
# 需要导入模块: from simpletemplate import SimpleTemplate [as 别名]
# 或者: from simpletemplate.SimpleTemplate import render [as 别名]
def get_form(self,value=''):
body = ("""<input type="text" name"${name}"
value="${value}" """
"""${attrs} />""")
t = SimpleTemplate(body)
return t.render({'name':self.name, 'value':value,
'attrs':self.attrs})
示例2: listurl
# 需要导入模块: from simpletemplate import SimpleTemplate [as 别名]
# 或者: from simpletemplate.SimpleTemplate import render [as 别名]
def listurl(_request):
res = Response()
rsslist = Rssurl.select()
t = SimpleTemplate(file_path=relativepath('urllist.html'))
body = t.render({'rsslist': rsslist})
res.set_body(body)
return res
示例3: index
# 需要导入模块: from simpletemplate import SimpleTemplate [as 别名]
# 或者: from simpletemplate.SimpleTemplate import render [as 别名]
def index(_request, d={'counter': '0'}):
body = """<html><body><p>${counter}</p></body></html>"""
res = Response()
t = SimpleTemplate(body)
body = t.render(d)
d['counter'] = str(int(d['counter']) + 1)
res.set_body(body)
return res
示例4: index
# 需要导入模块: from simpletemplate import SimpleTemplate [as 别名]
# 或者: from simpletemplate.SimpleTemplate import render [as 别名]
def index(_request, foo='', d={'counter': '0'}):
body = base_body % ('<p>Logged in!</p>')
res = Response()
t = SimpleTemplate(body)
body = t.render(d)
d['counter'] = str(int(d['counter']) + 1)
res.set_body(body)
return res
示例5: login_form
# 需要导入模块: from simpletemplate import SimpleTemplate [as 别名]
# 或者: from simpletemplate.SimpleTemplate import render [as 别名]
def login_form(_request, values={}, errors={}):
body = base_body % ('${form.display(values, errors)}')
res = Response()
t = SimpleTemplate(body)
values['password'] = ''
body = t.render({'form': loginform, 'values': values, 'errors': errors})
res.set_body(body)
return res
示例6: display
# 需要导入模块: from simpletemplate import SimpleTemplate [as 别名]
# 或者: from simpletemplate.SimpleTemplate import render [as 别名]
def display(self, values={}, errors={}):
container = ""
for f in self.forms:
container += f.display(values.get(f.name, ""), errors.get(f.name, ""))
container += """<br clear="all" />"""
body = """<form ${attrs}>\n""" """${container}\n""" """</form>\n"""
t = SimpleTemplate(body)
return t.render({"attrs": self.attrs, "container": container})
示例7: login_form
# 需要导入模块: from simpletemplate import SimpleTemplate [as 别名]
# 或者: from simpletemplate.SimpleTemplate import render [as 别名]
def login_form(_request, values={}, errors={}):
res=Response()
t=SimpleTemplate(file_path=relativepath('form.html'))
values['password']=''
body=t.render({'form':loginform, 'values':values, 'errors':errors,
'message':u'ログイン'})
res.set_body(body)
return res
示例8: get_add_form
# 需要导入模块: from simpletemplate import SimpleTemplate [as 别名]
# 或者: from simpletemplate.SimpleTemplate import render [as 别名]
def get_add_form(values={}, errors={}):
res = Response()
t = SimpleTemplate(file_path=relativepath('form.html'))
body = t.render({'message': 'RSS巡回用URLの追加',
'form': addform,
'values': values, 'errors': errors})
res.set_body(body)
return res
示例9: test_process
# 需要导入模块: from simpletemplate import SimpleTemplate [as 别名]
# 或者: from simpletemplate.SimpleTemplate import render [as 别名]
def test_process(self):
with mock.patch('simpletemplate.SimpleTemplate.process') as m:
m.return_value = [0, '']
t = SimpleTemplate('value')
o = t.render()
self.assertEqual(m.call_count, 1)
self.assertEqual('', o)
示例10: get_label
# 需要导入模块: from simpletemplate import SimpleTemplate [as 别名]
# 或者: from simpletemplate.SimpleTemplate import render [as 别名]
def get_label(self, error):
body = ("""<label for="${name}">${label}\n"""
"""$if error:\n"""
"""<span class="error">${error}</span>\n"""
"""$endif\n"""
"""</label>""")
t = SimpleTemplate(body)
return t.render({'name': self.name, 'label': self.label, 'error': error})
示例11: test_call_stbookmarkform
# 需要导入模块: from simpletemplate import SimpleTemplate [as 别名]
# 或者: from simpletemplate.SimpleTemplate import render [as 别名]
def test_call_stbookmarkform(self):
p=path.join(path.dirname(__file__),"stbookmarkform.html")
t=SimpleTemplate(file_path=p)
value_dic={}
value_dic["message"]="Message"
value_dic["title"]="Title"
value_dic["url"]="URL"
value_dic["bookmarks"]=("Yahoo!","http://www.yahoo.co.jp")
body=t.render(value_dic)
print body
示例12: display
# 需要导入模块: from simpletemplate import SimpleTemplate [as 别名]
# 或者: from simpletemplate.SimpleTemplate import render [as 别名]
def display(self, values={}, errors={}):
container = ''
for f in self.forms:
container += f.display(values.get(f.name, ''), errors.get(f.name, ''))
container += """<br clear="all" />"""
body = ("""<form ${attrs}>\n"""
"""${container}\n"""
"""</form>\n""")
t = SimpleTemplate(body)
return t.render({'attrs': self.attrs, 'container': container})
示例13: get_form
# 需要导入模块: from simpletemplate import SimpleTemplate [as 别名]
# 或者: from simpletemplate.SimpleTemplate import render [as 别名]
def get_form(self, value=''):
body = ("""$for v in options:\n"""
"""${v[1]} : """
"""<input type="radio" name="${name}" value="${v[0]}"\n"""
"""$if value==v[0]:\n"""
""" checked \n"""
"""$endif\n"""
"""/>\n"""
"""$endfor\n""")
t = SimpleTemplate(body)
return t.render({'name': self.name, 'value': value, 'options':self.options, 'attrs': self.attrs})
示例14: test_process2
# 需要导入模块: from simpletemplate import SimpleTemplate [as 别名]
# 或者: from simpletemplate.SimpleTemplate import render [as 别名]
def test_process2(self):
t = SimpleTemplate("""
$if True:
test
$endif
""")
body = t.render({})
self.assertEqual("""
test
""", body)
示例15: get_edit_form
# 需要导入模块: from simpletemplate import SimpleTemplate [as 别名]
# 或者: from simpletemplate.SimpleTemplate import render [as 别名]
def get_edit_form(item_id, values={}, errors={}):
res = Response()
t = SimpleTemplate(file_path=relativepath('form.html'))
if not values:
for item in Rssurl.select(id=item_id):
pass
values = {'item_id': item_id, 'title':item.title, 'url': item.url}
body = t.render({'message': 'RSS巡回用URLの編集',
'form': editform,
'values': values, 'errors': errors})
res.set_body(body)
return res