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


Python blocks.RawHTMLBlock方法代碼示例

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


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

示例1: get_comparison_class_for_block

# 需要導入模塊: from wagtail.core import blocks [as 別名]
# 或者: from wagtail.core.blocks import RawHTMLBlock [as 別名]
def get_comparison_class_for_block(block):
    if hasattr(block, 'get_comparison_class'):
        return block.get_comparison_class()
    elif isinstance(block, (blocks.CharBlock, blocks.TextBlock)):
        return CharBlockComparison
    elif isinstance(block, blocks.RawHTMLBlock):
        # Compare raw HTML blocks as if they were plain text, so that tags are shown explicitly
        return CharBlockComparison
    elif isinstance(block, blocks.RichTextBlock):
        return RichTextBlockComparison
    elif isinstance(block, blocks.StructBlock):
        return StructBlockComparison
    else:
        # As all stream field blocks have a HTML representation, fall back to diffing that.
        return RichTextBlockComparison 
開發者ID:wagtail,項目名稱:wagtail,代碼行數:17,代碼來源:compare.py

示例2: test_get_default_with_fallback_value

# 需要導入模塊: from wagtail.core import blocks [as 別名]
# 或者: from wagtail.core.blocks import RawHTMLBlock [as 別名]
def test_get_default_with_fallback_value(self):
        default_value = blocks.RawHTMLBlock().get_default()
        self.assertEqual(default_value, '')
        self.assertIsInstance(default_value, SafeData) 
開發者ID:wagtail,項目名稱:wagtail,代碼行數:6,代碼來源:test_blocks.py

示例3: test_get_default_with_none

# 需要導入模塊: from wagtail.core import blocks [as 別名]
# 或者: from wagtail.core.blocks import RawHTMLBlock [as 別名]
def test_get_default_with_none(self):
        default_value = blocks.RawHTMLBlock(default=None).get_default()
        self.assertEqual(default_value, '')
        self.assertIsInstance(default_value, SafeData) 
開發者ID:wagtail,項目名稱:wagtail,代碼行數:6,代碼來源:test_blocks.py

示例4: test_get_default_with_empty_string

# 需要導入模塊: from wagtail.core import blocks [as 別名]
# 或者: from wagtail.core.blocks import RawHTMLBlock [as 別名]
def test_get_default_with_empty_string(self):
        default_value = blocks.RawHTMLBlock(default='').get_default()
        self.assertEqual(default_value, '')
        self.assertIsInstance(default_value, SafeData) 
開發者ID:wagtail,項目名稱:wagtail,代碼行數:6,代碼來源:test_blocks.py

示例5: test_get_default_with_nonempty_string

# 需要導入模塊: from wagtail.core import blocks [as 別名]
# 或者: from wagtail.core.blocks import RawHTMLBlock [as 別名]
def test_get_default_with_nonempty_string(self):
        default_value = blocks.RawHTMLBlock(default='<blink>BÖÖM</blink>').get_default()
        self.assertEqual(default_value, '<blink>BÖÖM</blink>')
        self.assertIsInstance(default_value, SafeData) 
開發者ID:wagtail,項目名稱:wagtail,代碼行數:6,代碼來源:test_blocks.py

示例6: test_deserialize

# 需要導入模塊: from wagtail.core import blocks [as 別名]
# 或者: from wagtail.core.blocks import RawHTMLBlock [as 別名]
def test_deserialize(self):
        block = blocks.RawHTMLBlock()
        result = block.to_python('<blink>BÖÖM</blink>')
        self.assertEqual(result, '<blink>BÖÖM</blink>')
        self.assertIsInstance(result, SafeData) 
開發者ID:wagtail,項目名稱:wagtail,代碼行數:7,代碼來源:test_blocks.py

示例7: test_render

# 需要導入模塊: from wagtail.core import blocks [as 別名]
# 或者: from wagtail.core.blocks import RawHTMLBlock [as 別名]
def test_render(self):
        block = blocks.RawHTMLBlock()
        result = block.render(mark_safe('<blink>BÖÖM</blink>'))
        self.assertEqual(result, '<blink>BÖÖM</blink>')
        self.assertIsInstance(result, SafeData) 
開發者ID:wagtail,項目名稱:wagtail,代碼行數:7,代碼來源:test_blocks.py

示例8: test_render_form

# 需要導入模塊: from wagtail.core import blocks [as 別名]
# 或者: from wagtail.core.blocks import RawHTMLBlock [as 別名]
def test_render_form(self):
        block = blocks.RawHTMLBlock()
        result = block.render_form(mark_safe('<blink>BÖÖM</blink>'), prefix='rawhtml')
        self.assertIn('<textarea ', result)
        self.assertIn('name="rawhtml"', result)
        self.assertIn('&lt;blink&gt;BÖÖM&lt;/blink&gt;', result) 
開發者ID:wagtail,項目名稱:wagtail,代碼行數:8,代碼來源:test_blocks.py

示例9: test_form_response

# 需要導入模塊: from wagtail.core import blocks [as 別名]
# 或者: from wagtail.core.blocks import RawHTMLBlock [as 別名]
def test_form_response(self):
        block = blocks.RawHTMLBlock()
        result = block.value_from_datadict({'rawhtml': '<blink>BÖÖM</blink>'}, {}, prefix='rawhtml')
        self.assertEqual(result, '<blink>BÖÖM</blink>')
        self.assertIsInstance(result, SafeData) 
開發者ID:wagtail,項目名稱:wagtail,代碼行數:7,代碼來源:test_blocks.py

示例10: test_value_omitted_from_data

# 需要導入模塊: from wagtail.core import blocks [as 別名]
# 或者: from wagtail.core.blocks import RawHTMLBlock [as 別名]
def test_value_omitted_from_data(self):
        block = blocks.RawHTMLBlock()
        self.assertFalse(block.value_omitted_from_data({'rawhtml': 'ohai'}, {}, 'rawhtml'))
        self.assertFalse(block.value_omitted_from_data({'rawhtml': ''}, {}, 'rawhtml'))
        self.assertTrue(block.value_omitted_from_data({'nothing-here': 'nope'}, {}, 'rawhtml')) 
開發者ID:wagtail,項目名稱:wagtail,代碼行數:7,代碼來源:test_blocks.py

示例11: test_clean_nonrequired_field

# 需要導入模塊: from wagtail.core import blocks [as 別名]
# 或者: from wagtail.core.blocks import RawHTMLBlock [as 別名]
def test_clean_nonrequired_field(self):
        block = blocks.RawHTMLBlock(required=False)
        result = block.clean(mark_safe('<blink>BÖÖM</blink>'))
        self.assertEqual(result, '<blink>BÖÖM</blink>')
        self.assertIsInstance(result, SafeData)

        result = block.clean(mark_safe(''))
        self.assertEqual(result, '')
        self.assertIsInstance(result, SafeData) 
開發者ID:wagtail,項目名稱:wagtail,代碼行數:11,代碼來源:test_blocks.py

示例12: test_render_with_validator

# 需要導入模塊: from wagtail.core import blocks [as 別名]
# 或者: from wagtail.core.blocks import RawHTMLBlock [as 別名]
def test_render_with_validator(self):
        def validate_contains_foo(value):
            if 'foo' not in value:
                raise ValidationError("Value must contain 'foo'")

        block = blocks.RawHTMLBlock(validators=[validate_contains_foo])

        with self.assertRaises(ValidationError):
            block.clean(mark_safe('<p>bar</p>')) 
開發者ID:wagtail,項目名稱:wagtail,代碼行數:11,代碼來源:test_blocks.py


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