Creating an upcoming event lists from local calendar

I have a local HA calendar that I put maintenance/house hold to dos on.

Right now I’m using a static entry or a helper to set the next occurrence, it would be great if I could turn this into a template that reads the local calendar and populate this markdown.

Is this possible?

{% set idate = (state_attr('input_datetime.vehicle_inspection_due', 'timestamp') | timestamp_custom('%m/%d/%Y')) %}
{% set rdate = (state_attr('input_datetime.vehicle_registration_due', 'timestamp') | timestamp_custom('%m/%d/%Y')) %}
{% set acfilter = "9/1/2024" %}
{% set realestate1 = "12/1/2025" %}
{% set realestate2 = "5/15/2026" %}
Car Inspection due in {{ (strptime(idate, '%m/%d/%Y', today_at()) | as_local - today_at()).days }} day(s) on {{ idate }}
Car Registeration due in {{ (strptime(rdate, '%m/%d/%Y', today_at()) | as_local - today_at()).days }} day(s) on {{ rdate }}
A/C Filter Replacement due in {{ (strptime(acfilter, '%m/%d/%Y', today_at()) | as_local - today_at()).days }} days(s) {{ acfilter }}
Home RE Taxes Part 1 due in {{ (strptime(realestate1, '%m/%d/%Y', today_at()) | as_local - today_at()).days }} days(s) {{ realestate1 }}
Home RE Taxes Part 2 due in {{ (strptime(realestate2, '%m/%d/%Y', today_at()) | as_local - today_at()).days }} days(s) {{ realestate2 }}

There’s a HACS card that does this:

Screenshot 2024-04-28 17.11.51

I did look at this card. It seems to require an external entity to loop through. Is there a way of just looping the events from the calendar?

This is how far I got:
Nevermind, entities is (optional). Thank you very much @Stiltjack

type: custom:home-feed-card
title: Upcoming tasks
card_id: upcoming_tasks
show_empty: false
calendars:
  - calendar.hacal
more_info_on_tap: false
state_color: true
calendar_days_forward: 120

@Stiltjack any idea on how to format the content so that it shows the number days until event rather than the actual date? I’ve tried to override the default format and haven’t been able to.

I’ve only used the default, which is relative time. I think the only other options are date and time.