I know this is technically over 100 lines but python line limits don't apply to templates and honestly I think this is less readable on the next line like that.