当前位置: 首页>>代码示例>>Python>>正文


Python DOM.render方法代码示例

本文整理汇总了Python中draftjs_exporter.dom.DOM.render方法的典型用法代码示例。如果您正苦于以下问题:Python DOM.render方法的具体用法?Python DOM.render怎么用?Python DOM.render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在draftjs_exporter.dom.DOM的用法示例。


在下文中一共展示了DOM.render方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: render

# 需要导入模块: from draftjs_exporter.dom import DOM [as 别名]
# 或者: from draftjs_exporter.dom.DOM import render [as 别名]
    def render(self, content_state=None):
        """
        Starts the export process on a given piece of content state.
        """
        if content_state is None:
            content_state = {}

        blocks = content_state.get('blocks', [])
        wrapper_state = WrapperState(self.block_map, blocks)
        document = DOM.create_element()
        entity_map = content_state.get('entityMap', {})
        min_depth = 0

        for block in blocks:
            depth = block['depth']
            elt = self.render_block(block, entity_map, wrapper_state)

            if depth > min_depth:
                min_depth = depth

            # At level 0, append the element to the document.
            if depth == 0:
                DOM.append_child(document, elt)

        # If there is no block at depth 0, we need to add the wrapper that contains the whole tree to the document.
        if min_depth > 0 and wrapper_state.stack.length() != 0:
            DOM.append_child(document, wrapper_state.stack.tail().elt)

        return DOM.render(document)
开发者ID:springload,项目名称:draftjs_exporter,代码行数:31,代码来源:html.py

示例2: test_render_www

# 需要导入模块: from draftjs_exporter.dom import DOM [as 别名]
# 或者: from draftjs_exporter.dom.DOM import render [as 别名]
    def test_render_www(self):
        match = next(LINKIFY_DECORATOR['strategy'].finditer('test www.example.com'))

        self.assertEqual(DOM.render(DOM.create_element(LINKIFY_DECORATOR['component'], {
            'block': {'type': BLOCK_TYPES.UNSTYLED},
            'match': match,
        }, match.group(0))), '<a href="http://www.example.com">www.example.com</a>')
开发者ID:springload,项目名称:draftjs_exporter,代码行数:9,代码来源:test_composite_decorators.py

示例3: test_render_decorators_conflicting_order_two

# 需要导入模块: from draftjs_exporter.dom import DOM [as 别名]
# 或者: from draftjs_exporter.dom.DOM import render [as 别名]
 def test_render_decorators_conflicting_order_two(self):
     self.assertEqual(DOM.render(render_decorators([HASHTAG_DECORATOR, LINKIFY_DECORATOR], 'test https://www.example.com#hash #hashtagtest', {'type': BLOCK_TYPES.UNSTYLED, 'depth': 0}, [])), 'test https://www.example.com<span class="hashtag">#hash</span> <span class="hashtag">#hashtagtest</span>')
开发者ID:springload,项目名称:draftjs_exporter,代码行数:4,代码来源:test_composite_decorators.py

示例4: test_render_decorators_single

# 需要导入模块: from draftjs_exporter.dom import DOM [as 别名]
# 或者: from draftjs_exporter.dom.DOM import render [as 别名]
 def test_render_decorators_single(self):
     self.assertEqual(DOM.render(render_decorators([LINKIFY_DECORATOR], 'test https://www.example.com#hash #hashtagtest', {'type': BLOCK_TYPES.UNSTYLED, 'depth': 0}, [])), 'test <a href="https://www.example.com#hash">https://www.example.com#hash</a> #hashtagtest')
开发者ID:springload,项目名称:draftjs_exporter,代码行数:4,代码来源:test_composite_decorators.py

示例5: test_render

# 需要导入模块: from draftjs_exporter.dom import DOM [as 别名]
# 或者: from draftjs_exporter.dom.DOM import render [as 别名]
 def test_render(self):
     self.assertEqual(DOM.render(DOM.create_element(BR_DECORATOR['component'], {'block': {'type': BLOCK_TYPES.UNSTYLED}}, '\n')), '<br/>')
开发者ID:springload,项目名称:draftjs_exporter,代码行数:4,代码来源:test_composite_decorators.py

示例6: test_render_without_icon

# 需要导入模块: from draftjs_exporter.dom import DOM [as 别名]
# 或者: from draftjs_exporter.dom.DOM import render [as 别名]
 def test_render_without_icon(self):
     self.assertEqual(DOM.render(DOM.create_element(button, {
         'href': 'http://example.com',
         'text': 'Launch',
     })), '<a href="http://example.com">Launch</a>')
开发者ID:springload,项目名称:draftjs_exporter,代码行数:7,代码来源:test_entities.py

示例7: test_render_with_icon

# 需要导入模块: from draftjs_exporter.dom import DOM [as 别名]
# 或者: from draftjs_exporter.dom.DOM import render [as 别名]
 def test_render_with_icon(self):
     self.assertEqual(DOM.render(DOM.create_element(button, {
         'href': 'http://example.com',
         'icon': 'rocket',
         'text': 'Launch',
     })), '<a class="icon-text" href="http://example.com"><svg class="icon"><use xlink:href="#icon-rocket"></use></svg><span class="icon-text__text">Launch</span></a>')
开发者ID:springload,项目名称:draftjs_exporter,代码行数:8,代码来源:test_entities.py

示例8: test_render

# 需要导入模块: from draftjs_exporter.dom import DOM [as 别名]
# 或者: from draftjs_exporter.dom.DOM import render [as 别名]
 def test_render(self):
     self.assertEqual(DOM.render(DOM.create_element(link, {
         'url': 'http://example.com',
     }, 'wow')), '<a href="http://example.com">wow</a>')
开发者ID:springload,项目名称:draftjs_exporter,代码行数:6,代码来源:test_entities.py


注:本文中的draftjs_exporter.dom.DOM.render方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。