File tree Expand file tree Collapse file tree 4 files changed +38
-3
lines changed
Expand file tree Collapse file tree 4 files changed +38
-3
lines changed Original file line number Diff line number Diff line change 11{% extends "base.html" %}
2- {% load static %}
2+ {% load static content_filters %}
33{% block content %}
44< main >
55 < div class ="min-h-screen bg-contain bg-center " style ="background-image: url('{% static 'img/bg-conference-at-glance.png' %}'); ">
1010 < article >
1111 < h1 class ="text-5xl my-10 font-bold font-td_pinoy text-orange-2 hyphens-auto "> {{ page.title|safe }}</ h1 >
1212 < div class ="prose prose-lg max-w-none prose-custom ">
13- {{ page.content|safe }}
13+ {{ page.content|render_buttons }}
1414 </ div >
1515 </ article >
1616 </ div >
Original file line number Diff line number Diff line change 1+ import re
2+
3+ from django import template
4+ from django .utils .html import mark_safe
5+
6+ register = template .Library ()
7+
8+
9+ def _replace_btn_link (match ):
10+ attrs = match .group (1 )
11+ text = match .group (2 )
12+
13+ if "|btn" not in text :
14+ return match .group (0 )
15+
16+ clean_text = text .replace ("|btn" , "" ).strip ()
17+
18+ if "class=" in attrs :
19+ attrs = re .sub (r'class=["\']([^"\']*)["\']' , r'class="\1 btn btn-primary"' , attrs )
20+ else :
21+ attrs += ' class="btn btn-primary"'
22+
23+ return f"<a { attrs } >{ clean_text } </a>"
24+
25+
26+ @register .filter
27+ def render_buttons (value ):
28+ """Convert links with |btn marker in their text to button-styled links.
29+
30+ Usage in TinyMCE: set link text to "Click here|btn"
31+ Output: <a href="..." class="btn btn-primary">Click here</a>
32+ """
33+ result = re .sub (r"<a\s+([^>]+)>([^<]*\|btn[^<]*)</a>" , _replace_btn_link , value )
34+ return mark_safe (result )
Original file line number Diff line number Diff line change 22Announcement modal component. Displays the latest published announcement from the database.
33The modal is dismissible and won't show again until browser session is closed or cache is cleared.
44{% endcomment %}
5+ {% load content_filters %}
56
67{% if latest_announcement %}
78< dialog id ="announcement-modal " class ="modal " open >
1112 </ form >
1213 < h3 class ="font-bold text-2xl mb-4 "> 📢 {{ latest_announcement.title }}</ h3 >
1314 < div class ="py-4 prose prose-sm max-w-none [&_p]:text-lg [&_p]:pb-4 [&_h1]:text-lg [&_h2]:text-xl ">
14- {{ latest_announcement.content|safe }}
15+ {{ latest_announcement.content|render_buttons }}
1516 </ div >
1617 </ div >
1718 < form method ="dialog " class ="modal-backdrop ">
You can’t perform that action at this time.
0 commit comments