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


Python HalloRichTextArea.render方法代码示例

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


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

示例1: test_default_features

# 需要导入模块: from wagtail.admin.rich_text import HalloRichTextArea [as 别名]
# 或者: from wagtail.admin.rich_text.HalloRichTextArea import render [as 别名]
    def test_default_features(self):
        widget = HalloRichTextArea()

        result = widget.render(
            'foo',
            '<p>a <a linktype="page" id="3">page</a> and a <a linktype="document" id="1">document</a></p>',
            {'id': 'id_foo'},
        )
        soup = BeautifulSoup(result, 'html.parser')
        result_value = soup.textarea.string

        self.assertHTMLEqual(result_value, '<p>a <a data-linktype="page" data-id="3" data-parent-id="2" href="/events/">page</a> and a <a data-linktype="document" data-id="1" href="/documents/1/test.pdf">document</a></p>')
开发者ID:mwharrison,项目名称:wagtail,代码行数:14,代码来源:test_rich_text.py

示例2: test_custom_features

# 需要导入模块: from wagtail.admin.rich_text import HalloRichTextArea [as 别名]
# 或者: from wagtail.admin.rich_text.HalloRichTextArea import render [as 别名]
    def test_custom_features(self):
        widget = HalloRichTextArea(features=['h1', 'link', 'somethingijustmadeup'])

        result = widget.render(
            'foo',
            '<p>a <a linktype="page" id="3">page</a> and a <a linktype="document" id="1">document</a></p>',
            {'id': 'id_foo'},
        )
        soup = BeautifulSoup(result, 'html.parser')
        result_value = soup.textarea.string

        self.assertHTMLEqual(result_value, '<p>a <a data-linktype="page" data-id="3" data-parent-id="2" href="/events/">page</a> and a <a>document</a></p>')
开发者ID:mwharrison,项目名称:wagtail,代码行数:14,代码来源:test_rich_text.py

示例3: test_heading_order

# 需要导入模块: from wagtail.admin.rich_text import HalloRichTextArea [as 别名]
# 或者: from wagtail.admin.rich_text.HalloRichTextArea import render [as 别名]
    def test_heading_order(self):
        # Using the `register_rich_text_features` doesn't work here,
        # probably because the features have already been scanned at that point.
        # Extending the registry directly instead.
        feature_registry.default_features.extend(['h1', 'h5', 'h6'])

        widget = HalloRichTextArea()
        html = widget.render('the_name', '<p>the value</p>', attrs={'id': 'the_id'})

        expected_options = (
            '"halloheadings": {"formatBlocks": ["p", "h1", "h2", "h3", "h4", "h5", "h6"]}'
        )
        self.assertIn(expected_options, html)
开发者ID:Proper-Job,项目名称:wagtail,代码行数:15,代码来源:test_rich_text.py


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