本文整理匯總了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>'))