Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap 'card' description with appropriate HTML tags #4360

Merged
merged 3 commits into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
<div class="full-bleed-xs d-flex flex-1">
<div class="key-item mx-2 mx-md-3 p-3 w-100 d-flex flex-column">
<h3 class="h3-heading mb-2">{{ title }}</h3>
<p>{{ description | richtext }}</p>
{% if description_is_rich_text %}
{{ description|richtext }}
{% else %}
<p>{{ description }}</p>
{% endif %}
<a class="cta-link mb-2" href="{{ link_url }}">{{ link_label }}</a>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions network-api/networkapi/wagtailpages/templatetags/card_tags.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
from django import template
from bs4 import BeautifulSoup

register = template.Library()


@register.inclusion_tag('wagtailpages/tags/card.html')
def card(image, title, description, link_url, link_label, commitment=None):
parsedDescription = BeautifulSoup(description, 'html.parser')

return {
'image': image,
'title': title,
'description': description,
'description_is_rich_text': len(parsedDescription.find_all(True)) > 0,
'link_url': link_url,
'link_label': link_label,
'commitment': commitment,
Expand Down