feat: add filter to convert month number to name
All checks were successful
Build and Deploy Static Site / build (push) Successful in 57s
All checks were successful
Build and Deploy Static Site / build (push) Successful in 57s
Added a custom filter `month_name` to convert month numbers to their full names in templates. Updated the Transparency Report title to use this filter, enhancing readability and user experience. This change ensures that month names are displayed instead of numeric values, making the report titles clearer and more user-friendly.
This commit is contained in:
parent
feb273a8b0
commit
5cdb9ad43b
2 changed files with 9 additions and 1 deletions
8
main.py
8
main.py
|
@ -34,6 +34,14 @@ def icon(icon_name):
|
|||
env.filters["icon"] = icon
|
||||
|
||||
|
||||
# Filter for rendering a month name from a number
|
||||
def month_name(month_number):
|
||||
return datetime.date(1900, int(month_number), 1).strftime("%B")
|
||||
|
||||
|
||||
env.filters["month_name"] = month_name
|
||||
|
||||
|
||||
def render_template_to_file(template_name, output_name, **kwargs):
|
||||
try:
|
||||
template = env.get_template(template_name)
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
{% for month, month_data in year_data.items() %}
|
||||
<div class="card shadow-sm mt-4">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Transparency Report for {{ month }}/{{ year }}</h5>
|
||||
<h5 class="card-title">Transparency Report for {{ month|month_name }} {{ year }}</h5>
|
||||
<div class="table-responsive">{{ month_data|safe }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue