QuoteWidget API¶
QuoteWidget(widget_id=None)
¶
Bases: BaseWidget
Create a quote-style text block for highlighting quoted content.
This widget is perfect for quoting famous sayings, customer reviews, important statements, or literature excerpts in emails. It distinguishes itself from other text by adding a colored vertical line on the left side, making it visually more prominent.
Core features
- Content attribution: Supports setting the author and source of the quote.
- Theming: The left border color of the quote can change based on status type (such as INFO, SUCCESS, WARNING).
Attributes:
Name | Type | Description |
---|---|---|
content |
str
|
The main text content being quoted. |
author |
Optional[str]
|
Author of the quote. |
source |
Optional[str]
|
Source or origin of the quote. |
quote_type |
StatusType
|
Type of quote, determines the color of the left border. |
Examples:
Create a classic famous quote:
from email_widget.widgets import QuoteWidget
from email_widget.core.enums import StatusType
quote = (QuoteWidget() .set_content("The only way to do great work is to love what you do.") .set_author("Steve Jobs") .set_quote_type(StatusType.INFO))
# Assuming email is an Email object
# email.add_widget(quote)
Create a quote for showcasing customer testimonials:
customer_feedback = (QuoteWidget() .set_content("This new feature has significantly improved our workflow!") .set_author("Satisfied Customer") .set_source("Feedback Survey") .set_quote_type(StatusType.SUCCESS))
Initialize QuoteWidget.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
widget_id
|
Optional[str]
|
Optional Widget ID. |
None
|
Functions¶
clear_attribution()
¶
Clear author and source information.
Returns:
Name | Type | Description |
---|---|---|
QuoteWidget |
QuoteWidget
|
Returns self to support method chaining. |
Examples:
get_template_context()
¶
Get template context data required for rendering
set_author(author)
¶
Set the author of the quote.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
author
|
str
|
Author name. |
required |
Returns:
Name | Type | Description |
---|---|---|
QuoteWidget |
QuoteWidget
|
Returns self to support method chaining. |
Examples:
set_content(content)
¶
Set the main text content of the quote.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
str
|
The text content to be quoted. |
required |
Returns:
Name | Type | Description |
---|---|---|
QuoteWidget |
QuoteWidget
|
Returns self to support method chaining. |
Examples:
set_full_quote(content, author=None, source=None)
¶
Set complete quote information at once.
This method allows you to set quote content, author, and source simultaneously for quick configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
str
|
Quote content. |
required |
author
|
str
|
Optional author name. |
None
|
source
|
str
|
Optional source description. |
None
|
Returns:
Name | Type | Description |
---|---|---|
QuoteWidget |
QuoteWidget
|
Returns self to support method chaining. |
Examples:
set_quote_type(quote_type)
¶
Set the type of the quote.
This type determines the color of the left border of the quote block.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
quote_type
|
StatusType
|
Quote type enum value. |
required |
Returns:
Name | Type | Description |
---|---|---|
QuoteWidget |
QuoteWidget
|
Returns self to support method chaining. |
Examples:
set_source(source)
¶
Set the source of the quote.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
str
|
Source description (such as book name, website, report, etc.). |
required |
Returns:
Name | Type | Description |
---|---|---|
QuoteWidget |
QuoteWidget
|
Returns self to support method chaining. |
Examples: