当前位置: 首页>>代码示例>>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;未经允许,请勿转载。