當前位置: 首頁>>代碼示例>>Python>>正文


Python HalloRichTextArea.value_from_datadict方法代碼示例

本文整理匯總了Python中wagtail.admin.rich_text.HalloRichTextArea.value_from_datadict方法的典型用法代碼示例。如果您正苦於以下問題:Python HalloRichTextArea.value_from_datadict方法的具體用法?Python HalloRichTextArea.value_from_datadict怎麽用?Python HalloRichTextArea.value_from_datadict使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在wagtail.admin.rich_text.HalloRichTextArea的用法示例。


在下文中一共展示了HalloRichTextArea.value_from_datadict方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_embed_conversion_with_default_whitelist

# 需要導入模塊: from wagtail.admin.rich_text import HalloRichTextArea [as 別名]
# 或者: from wagtail.admin.rich_text.HalloRichTextArea import value_from_datadict [as 別名]
    def test_embed_conversion_with_default_whitelist(self):
        widget = HalloRichTextArea()

        result = widget.value_from_datadict({
            'body': '<p>image <img src="foo" data-embedtype="image" data-id="123" data-format="left" data-alt="test alt" /> embed <span data-embedtype="media" data-url="https://www.youtube.com/watch?v=vwyuB8QKzBI">blah</span> badger <span data-embedtype="badger" data-colour="black-and-white">badger</span></p>'
        }, {}, 'body')
        self.assertHTMLEqual(result, '<p>image <embed embedtype="image" id="123" format="left" alt="test alt" /> embed <embed embedtype="media" url="https://www.youtube.com/watch?v=vwyuB8QKzBI" /> badger </p>')
開發者ID:mwharrison,項目名稱:wagtail,代碼行數:9,代碼來源:test_rich_text.py

示例2: test_embed_conversion_with_custom_whitelist

# 需要導入模塊: from wagtail.admin.rich_text import HalloRichTextArea [as 別名]
# 或者: from wagtail.admin.rich_text.HalloRichTextArea import value_from_datadict [as 別名]
    def test_embed_conversion_with_custom_whitelist(self):
        widget = HalloRichTextArea(features=['h1', 'bold', 'image', 'somethingijustmadeup'])

        result = widget.value_from_datadict({
            'body': '<p>image <img src="foo" data-embedtype="image" data-id="123" data-format="left" data-alt="test alt" /> embed <span data-embedtype="media" data-url="https://www.youtube.com/watch?v=vwyuB8QKzBI">blah</span></p>'
        }, {}, 'body')
        self.assertHTMLEqual(result, '<p>image <embed embedtype="image" id="123" format="left" alt="test alt" /> embed </p>')
開發者ID:mwharrison,項目名稱:wagtail,代碼行數:9,代碼來源:test_rich_text.py

示例3: test_link_conversion_with_custom_whitelist

# 需要導入模塊: from wagtail.admin.rich_text import HalloRichTextArea [as 別名]
# 或者: from wagtail.admin.rich_text.HalloRichTextArea import value_from_datadict [as 別名]
    def test_link_conversion_with_custom_whitelist(self):
        widget = HalloRichTextArea(features=['h1', 'bold', 'link', 'somethingijustmadeup'])

        result = widget.value_from_datadict({
            'body': '<p>a <a href="/foo" data-linktype="page" data-id="123">page</a>, <a href="/foo" data-linktype="squirrel" data-id="234">a squirrel</a> and a <a href="/foo" data-linktype="document" data-id="345">document</a></p>'
        }, {}, 'body')
        self.assertHTMLEqual(result, '<p>a <a linktype="page" id="123">page</a>, a squirrel and a document</p>')
開發者ID:mwharrison,項目名稱:wagtail,代碼行數:9,代碼來源:test_rich_text.py

示例4: test_link_conversion_with_default_whitelist

# 需要導入模塊: from wagtail.admin.rich_text import HalloRichTextArea [as 別名]
# 或者: from wagtail.admin.rich_text.HalloRichTextArea import value_from_datadict [as 別名]
    def test_link_conversion_with_default_whitelist(self):
        widget = HalloRichTextArea()

        result = widget.value_from_datadict({
            'body': '<p>a <a href="/foo" data-linktype="page" data-id="123">page</a>, <a href="/foo" data-linktype="squirrel" data-id="234">a squirrel</a> and a <a href="/foo" data-linktype="document" data-id="345">document</a></p>'
        }, {}, 'body')
        self.assertHTMLEqual(result, '<p>a <a linktype="page" id="123">page</a>, a squirrel and a <a linktype="document" id="345">document</a></p>')
開發者ID:mwharrison,項目名稱:wagtail,代碼行數:9,代碼來源:test_rich_text.py

示例5: test_custom_whitelist

# 需要導入模塊: from wagtail.admin.rich_text import HalloRichTextArea [as 別名]
# 或者: from wagtail.admin.rich_text.HalloRichTextArea import value_from_datadict [as 別名]
 def test_custom_whitelist(self):
     widget = HalloRichTextArea(features=['h1', 'bold', 'somethingijustmadeup'])
     # accept elements that are represented in the feature list
     result = widget.value_from_datadict({
         'body': '<h1>h1</h1> <h2>h2</h2> <script>script</script> <p><b>bold</b> <i>italic</i></p> <blockquote>blockquote</blockquote>'
     }, {}, 'body')
     self.assertEqual(result, '<h1>h1</h1> h2 script <p><b>bold</b> italic</p> blockquote')
開發者ID:Proper-Job,項目名稱:wagtail,代碼行數:9,代碼來源:test_rich_text.py

示例6: test_default_whitelist

# 需要導入模塊: from wagtail.admin.rich_text import HalloRichTextArea [as 別名]
# 或者: from wagtail.admin.rich_text.HalloRichTextArea import value_from_datadict [as 別名]
    def test_default_whitelist(self):
        widget = HalloRichTextArea()

        # when no feature list is specified, accept elements that are part of the default set
        # (which includes h2)
        result = widget.value_from_datadict({
            'body': '<h2>heading</h2><script>script</script><blockquote>blockquote</blockquote>'
        }, {}, 'body')
        self.assertEqual(result, '<h2>heading</h2>scriptblockquote')
開發者ID:Proper-Job,項目名稱:wagtail,代碼行數:11,代碼來源:test_rich_text.py


注:本文中的wagtail.admin.rich_text.HalloRichTextArea.value_from_datadict方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。