本文整理汇总了Python中mustache.build函数的典型用法代码示例。如果您正苦于以下问题:Python build函数的具体用法?Python build怎么用?Python build使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了build函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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 |')
示例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'""')
示例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')
示例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'|---|')
示例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"')
示例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'"" == ""')
示例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"')
示例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|')
示例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')
示例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')
示例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')
示例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'|=|')
示例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')
示例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')