當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。