本文整理匯總了Python中wagtail.core.blocks.TextBlock方法的典型用法代碼示例。如果您正苦於以下問題:Python blocks.TextBlock方法的具體用法?Python blocks.TextBlock怎麽用?Python blocks.TextBlock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類wagtail.core.blocks
的用法示例。
在下文中一共展示了blocks.TextBlock方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_comparison_class_for_block
# 需要導入模塊: from wagtail.core import blocks [as 別名]
# 或者: from wagtail.core.blocks import TextBlock [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