本文整理汇总了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
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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('<blink>BÖÖM</blink>', result)
示例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)
示例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'))
示例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)
示例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>'))