本文整理汇总了Python中pystache.Renderer._make_resolve_partial方法的典型用法代码示例。如果您正苦于以下问题:Python Renderer._make_resolve_partial方法的具体用法?Python Renderer._make_resolve_partial怎么用?Python Renderer._make_resolve_partial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pystache.Renderer
的用法示例。
在下文中一共展示了Renderer._make_resolve_partial方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_make_resolve_partial__unicode
# 需要导入模块: from pystache import Renderer [as 别名]
# 或者: from pystache.Renderer import _make_resolve_partial [as 别名]
def test_make_resolve_partial__unicode(self):
"""
Test _make_resolve_partial(): that resolve_partial doesn't "double-decode" Unicode.
"""
renderer = Renderer()
renderer.partials = {'partial': 'foo'}
resolve_partial = renderer._make_resolve_partial()
self.assertEqual(resolve_partial("partial"), "foo")
# Now with a value that is already unicode.
renderer.partials = {'partial': 'foo'}
resolve_partial = renderer._make_resolve_partial()
# If the next line failed, we would get the following error:
# TypeError: decoding Unicode is not supported
self.assertEqual(resolve_partial("partial"), "foo")
示例2: test_make_resolve_partial
# 需要导入模块: from pystache import Renderer [as 别名]
# 或者: from pystache.Renderer import _make_resolve_partial [as 别名]
def test_make_resolve_partial(self):
"""
Test the _make_resolve_partial() method.
"""
renderer = Renderer()
renderer.partials = {'foo': 'bar'}
resolve_partial = renderer._make_resolve_partial()
actual = resolve_partial('foo')
self.assertEqual(actual, 'bar')
self.assertEqual(type(actual), str, "RenderEngine requires that "
"resolve_partial return unicode strings.")