本文整理汇总了Python中genshi.template.plugin.MarkupTemplateEnginePlugin.load_template方法的典型用法代码示例。如果您正苦于以下问题:Python MarkupTemplateEnginePlugin.load_template方法的具体用法?Python MarkupTemplateEnginePlugin.load_template怎么用?Python MarkupTemplateEnginePlugin.load_template使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类genshi.template.plugin.MarkupTemplateEnginePlugin
的用法示例。
在下文中一共展示了MarkupTemplateEnginePlugin.load_template方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_load_template_from_string
# 需要导入模块: from genshi.template.plugin import MarkupTemplateEnginePlugin [as 别名]
# 或者: from genshi.template.plugin.MarkupTemplateEnginePlugin import load_template [as 别名]
def test_load_template_from_string(self):
plugin = MarkupTemplateEnginePlugin()
tmpl = plugin.load_template(None, template_string="""<p>
$message
</p>""")
self.assertEqual(None, tmpl.filename)
assert isinstance(tmpl, MarkupTemplate)
示例2: test_helper_functions
# 需要导入模块: from genshi.template.plugin import MarkupTemplateEnginePlugin [as 别名]
# 或者: from genshi.template.plugin.MarkupTemplateEnginePlugin import load_template [as 别名]
def test_helper_functions(self):
plugin = MarkupTemplateEnginePlugin()
tmpl = plugin.load_template(PACKAGE + '.templates.functions')
output = plugin.render({'snippet': u'<b>Foo</b>'}, template=tmpl)
self.assertEqual("""<div>
False
bar
<b>Foo</b>
<b>Foo</b>
</div>""", output)
示例3: test_render
# 需要导入模块: from genshi.template.plugin import MarkupTemplateEnginePlugin [as 别名]
# 或者: from genshi.template.plugin.MarkupTemplateEnginePlugin import load_template [as 别名]
def test_render(self):
plugin = MarkupTemplateEnginePlugin()
tmpl = plugin.load_template(PACKAGE + '.templates.test')
output = plugin.render({'message': 'Hello'}, template=tmpl)
self.assertEqual("""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en">
<head>
<title>Test</title>
</head>
<body>
<h1>Test</h1>
<p>Hello</p>
</body>
</html>""", output)
示例4: test_render_fragment_with_doctype
# 需要导入模块: from genshi.template.plugin import MarkupTemplateEnginePlugin [as 别名]
# 或者: from genshi.template.plugin.MarkupTemplateEnginePlugin import load_template [as 别名]
def test_render_fragment_with_doctype(self):
plugin = MarkupTemplateEnginePlugin(options={
'genshi.default_doctype': 'html-strict',
})
tmpl = plugin.load_template(PACKAGE + '.templates.test_no_doctype')
output = plugin.render({'message': 'Hello'}, template=tmpl,
fragment=True)
self.assertEqual("""<html lang="en">
<head>
<title>Test</title>
</head>
<body>
<h1>Test</h1>
<p>Hello</p>
</body>
</html>""", output)
示例5: test_render_with_doctype
# 需要导入模块: from genshi.template.plugin import MarkupTemplateEnginePlugin [as 别名]
# 或者: from genshi.template.plugin.MarkupTemplateEnginePlugin import load_template [as 别名]
def test_render_with_doctype(self):
plugin = MarkupTemplateEnginePlugin(options={
'genshi.default_doctype': 'html-strict',
})
tmpl = plugin.load_template(PACKAGE + '.templates.test')
output = plugin.render({'message': 'Hello'}, template=tmpl)
self.assertEqual("""<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Test</title>
</head>
<body>
<h1>Test</h1>
<p>Hello</p>
</body>
</html>""", output)
示例6: test_transform_with_load
# 需要导入模块: from genshi.template.plugin import MarkupTemplateEnginePlugin [as 别名]
# 或者: from genshi.template.plugin.MarkupTemplateEnginePlugin import load_template [as 别名]
def test_transform_with_load(self):
plugin = MarkupTemplateEnginePlugin()
tmpl = plugin.load_template(PACKAGE + '.templates.test')
stream = plugin.transform({'message': 'Hello'}, tmpl)
assert isinstance(stream, Stream)
示例7: test_load_template_from_file
# 需要导入模块: from genshi.template.plugin import MarkupTemplateEnginePlugin [as 别名]
# 或者: from genshi.template.plugin.MarkupTemplateEnginePlugin import load_template [as 别名]
def test_load_template_from_file(self):
plugin = MarkupTemplateEnginePlugin()
tmpl = plugin.load_template(PACKAGE + '.templates.test')
self.assertEqual('test.html', os.path.basename(tmpl.filename))
assert isinstance(tmpl, MarkupTemplate)