本文整理匯總了Python中wagtail.admin.rich_text.HalloRichTextArea.render方法的典型用法代碼示例。如果您正苦於以下問題:Python HalloRichTextArea.render方法的具體用法?Python HalloRichTextArea.render怎麽用?Python HalloRichTextArea.render使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類wagtail.admin.rich_text.HalloRichTextArea
的用法示例。
在下文中一共展示了HalloRichTextArea.render方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_default_features
# 需要導入模塊: from wagtail.admin.rich_text import HalloRichTextArea [as 別名]
# 或者: from wagtail.admin.rich_text.HalloRichTextArea import render [as 別名]
def test_default_features(self):
widget = HalloRichTextArea()
result = widget.render(
'foo',
'<p>a <a linktype="page" id="3">page</a> and a <a linktype="document" id="1">document</a></p>',
{'id': 'id_foo'},
)
soup = BeautifulSoup(result, 'html.parser')
result_value = soup.textarea.string
self.assertHTMLEqual(result_value, '<p>a <a data-linktype="page" data-id="3" data-parent-id="2" href="/events/">page</a> and a <a data-linktype="document" data-id="1" href="/documents/1/test.pdf">document</a></p>')
示例2: test_custom_features
# 需要導入模塊: from wagtail.admin.rich_text import HalloRichTextArea [as 別名]
# 或者: from wagtail.admin.rich_text.HalloRichTextArea import render [as 別名]
def test_custom_features(self):
widget = HalloRichTextArea(features=['h1', 'link', 'somethingijustmadeup'])
result = widget.render(
'foo',
'<p>a <a linktype="page" id="3">page</a> and a <a linktype="document" id="1">document</a></p>',
{'id': 'id_foo'},
)
soup = BeautifulSoup(result, 'html.parser')
result_value = soup.textarea.string
self.assertHTMLEqual(result_value, '<p>a <a data-linktype="page" data-id="3" data-parent-id="2" href="/events/">page</a> and a <a>document</a></p>')
示例3: test_heading_order
# 需要導入模塊: from wagtail.admin.rich_text import HalloRichTextArea [as 別名]
# 或者: from wagtail.admin.rich_text.HalloRichTextArea import render [as 別名]
def test_heading_order(self):
# Using the `register_rich_text_features` doesn't work here,
# probably because the features have already been scanned at that point.
# Extending the registry directly instead.
feature_registry.default_features.extend(['h1', 'h5', 'h6'])
widget = HalloRichTextArea()
html = widget.render('the_name', '<p>the value</p>', attrs={'id': 'the_id'})
expected_options = (
'"halloheadings": {"formatBlocks": ["p", "h1", "h2", "h3", "h4", "h5", "h6"]}'
)
self.assertIn(expected_options, html)