本文整理汇总了Python中mustache.build函数的典型用法代码示例。如果您正苦于以下问题:Python build函数的具体用法?Python build怎么用?Python build使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了build函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __spec_test
def __spec_test(self, test_suite):
with open(self.PATH.format(test_suite), 'r') as fp:
suite = json.loads(fp.read())
tests = suite['tests']
for test in tests:
template = mustache.build(test['template'], test.get('partials'))
result = mustache.render(template, test['data'])
msg = '{}: {} != {}'.format(test['desc'], repr(str(test['expected'])), repr(str(result)))
self.assertEqual(result, test['expected'], msg)
开发者ID:mylokin,项目名称:mustache,代码行数:9,代码来源:test_mustache.py
示例2: test_partials_4
def test_partials_4(self):
template = u'| {{>partial}} |'
template = mustache.build(template, partials={u'partial': u'\t|\t'})
context = {}
rendered = mustache.render(template, context)
self.assertEqual(rendered, u'| \t|\t |')
开发者ID:mylokin,项目名称:mustache,代码行数:6,代码来源:test_mustache.py
示例3: test_inverted_1
def test_inverted_1(self):
template = u'"{{^boolean}}This should not be rendered.{{/boolean}}"'
template = mustache.build(template, partials=None)
context = {u'boolean': True}
rendered = mustache.render(template, context)
self.assertEqual(rendered, u'""')
开发者ID:mylokin,项目名称:mustache,代码行数:6,代码来源:test_mustache.py
示例4: test_partials_9
def test_partials_9(self):
template = u'\\\n {{>partial}}\n/\n'
template = mustache.build(template, partials={u'partial': u'|\n{{{content}}}\n|\n'})
context = {u'content': u'<\n->'}
rendered = mustache.render(template, context)
self.assertEqual(rendered, u'\\\n |\n <\n->\n |\n/\n')
开发者ID:mylokin,项目名称:mustache,代码行数:6,代码来源:test_mustache.py
示例5: test_interpolation_29
def test_interpolation_29(self):
template = u'|{{& string }}|'
template = mustache.build(template, partials=None)
context = {u'string': u'---'}
rendered = mustache.render(template, context)
self.assertEqual(rendered, u'|---|')
开发者ID:mylokin,项目名称:mustache,代码行数:6,代码来源:test_mustache.py
示例6: test_partials_0
def test_partials_0(self):
template = u'"{{>text}}"'
template = mustache.build(template, partials={u'text': u'from partial'})
context = {}
rendered = mustache.render(template, context)
self.assertEqual(rendered, u'"from partial"')
开发者ID:mylokin,项目名称:mustache,代码行数:6,代码来源:test_mustache.py
示例7: test_interpolation_19
def test_interpolation_19(self):
template = u'"{{a.b.c.name}}" == ""'
template = mustache.build(template, partials=None)
context = {u'a': {u'b': {}}, u'c': {u'name': u'Jim'}}
rendered = mustache.render(template, context)
self.assertEqual(rendered, u'"" == ""')
开发者ID:mylokin,项目名称:mustache,代码行数:6,代码来源:test_mustache.py
示例8: test_interpolation_16
def test_interpolation_16(self):
template = u'"{{&person.name}}" == "{{#person}}{{&name}}{{/person}}"'
template = mustache.build(template, partials=None)
context = {u'person': {u'name': u'Joe'}}
rendered = mustache.render(template, context)
self.assertEqual(rendered, u'"Joe" == "Joe"')
开发者ID:mylokin,项目名称:mustache,代码行数:6,代码来源:test_mustache.py
示例9: test_comments_4
def test_comments_4(self):
template = u'|\r\n{{! Standalone Comment }}\r\n|'
template = mustache.build(template, partials=None)
context = {}
rendered = mustache.render(template, context)
self.assertEqual(rendered, u'|\r\n|')
开发者ID:mylokin,项目名称:mustache,代码行数:6,代码来源:test_mustache.py
示例10: test_comments_3
def test_comments_3(self):
template = u'Begin.\n {{! Indented Comment Block! }}\nEnd.\n'
template = mustache.build(template, partials=None)
context = {}
rendered = mustache.render(template, context)
self.assertEqual(rendered, u'Begin.\nEnd.\n')
开发者ID:mylokin,项目名称:mustache,代码行数:6,代码来源:test_mustache.py
示例11: test_partials_5
def test_partials_5(self):
template = u' {{data}} {{> partial}}\n'
template = mustache.build(template, partials={u'partial': u'>\n>'})
context = {u'data': u'|'}
rendered = mustache.render(template, context)
self.assertEqual(rendered, u' | >\n>\n')
开发者ID:mylokin,项目名称:mustache,代码行数:6,代码来源:test_mustache.py
示例12: test_comments_1
def test_comments_1(self):
template = u'12345{{!\n This is a\n multi-line comment...\n}}67890\n'
template = mustache.build(template, partials=None)
context = {}
rendered = mustache.render(template, context)
self.assertEqual(rendered, u'1234567890\n')
开发者ID:mylokin,项目名称:mustache,代码行数:6,代码来源:test_mustache.py
示例13: test_sections_21
def test_sections_21(self):
template = u'|{{# boolean }}={{/ boolean }}|'
template = mustache.build(template, partials=None)
context = {u'boolean': True}
rendered = mustache.render(template, context)
self.assertEqual(rendered, u'|=|')
开发者ID:mylokin,项目名称:mustache,代码行数:6,代码来源:test_mustache.py
示例14: test_sections_20
def test_sections_20(self):
template = u'#{{#boolean}}\n/\n {{/boolean}}'
template = mustache.build(template, partials=None)
context = {u'boolean': True}
rendered = mustache.render(template, context)
self.assertEqual(rendered, u'#\n/\n')
开发者ID:mylokin,项目名称:mustache,代码行数:6,代码来源:test_mustache.py
示例15: test_sections_17
def test_sections_17(self):
template = u'| This Is\n {{#boolean}}\n|\n {{/boolean}}\n| A Line\n'
template = mustache.build(template, partials=None)
context = {u'boolean': True}
rendered = mustache.render(template, context)
self.assertEqual(rendered, u'| This Is\n|\n| A Line\n')
开发者ID:mylokin,项目名称:mustache,代码行数:6,代码来源:test_mustache.py
示例16: test_interpolation_10
def test_interpolation_10(self):
template = u'"{{&power}} jiggawatts!"'
template = mustache.build(template, partials=None)
context = {u'power': 1.21}
rendered = mustache.render(template, context)
self.assertEqual(rendered, u'"1.21 jiggawatts!"')
开发者ID:mylokin,项目名称:mustache,代码行数:6,代码来源:test_mustache.py
示例17: test_interpolation_13
def test_interpolation_13(self):
template = u'I ({{&cannot}}) be seen!'
template = mustache.build(template, partials=None)
context = {}
rendered = mustache.render(template, context)
self.assertEqual(rendered, u'I () be seen!')
开发者ID:mylokin,项目名称:mustache,代码行数:6,代码来源:test_mustache.py
示例18: test_comments_6
def test_comments_6(self):
template = u"Begin.\n {{!\n Something's going on here...\n }}\nEnd.\n"
template = mustache.build(template, partials=None)
context = {}
rendered = mustache.render(template, context)
self.assertEqual(rendered, u'Begin.\nEnd.\n')
开发者ID:mylokin,项目名称:mustache,代码行数:6,代码来源:test_mustache.py
示例19: test_interpolation_18
def test_interpolation_18(self):
template = u'"{{a.b.c}}" == ""'
template = mustache.build(template, partials=None)
context = {u'a': {}}
rendered = mustache.render(template, context)
self.assertEqual(rendered, u'"" == ""')
开发者ID:mylokin,项目名称:mustache,代码行数:6,代码来源:test_mustache.py
示例20: test_comments_7
def test_comments_7(self):
template = u' 12 {{! 34 }}\n'
template = mustache.build(template, partials=None)
context = {}
rendered = mustache.render(template, context)
self.assertEqual(rendered, u' 12 \n')
开发者ID:mylokin,项目名称:mustache,代码行数:6,代码来源:test_mustache.py
注:本文中的mustache.build函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论