Skip to content

Templatetags kwargs#2159

Merged
alastair merged 3 commits into
masterfrom
templatetags-kwargs
Jul 13, 2026
Merged

Templatetags kwargs#2159
alastair merged 3 commits into
masterfrom
templatetags-kwargs

Conversation

@alastair

Copy link
Copy Markdown
Member

Description
I noticed that it was getting difficult to correctly update all template tags every time we changed default values or added a new parameter.

Now, for any of our template tags that have a default parameter, require that they are explicitly defined when calling from the template

alastair added 3 commits July 10, 2026 11:21
This makes it easier to understand what a parameter to the templatetag
means, and prevents issues from needing to update all call sites
if the tag parameters change.
Update bw_paginator/bw_user_avatar/bw_tag, which are our most used tags
Finish adding required keyword arg names for our custom template tags

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes how optional parameters are handled in Django template tags by making them keyword-only in Python and updating template call sites accordingly, reducing the risk of silent behavior changes when defaults evolve.

Changes:

  • Make optional template-tag parameters keyword-only (using *) across several inclusion tags.
  • Update templates to pass optional parameters via explicit keywords (e.g., size=, anchor=, widget=).
  • Update docs and tests to reflect/validate the new calling convention.

Reviewed changes

Copilot reviewed 49 out of 65 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
templates/tags/tag_cloud.html Update bw_tag usage to keyword arguments.
templates/sounds/sound.html Convert multiple template tag calls (bw_sound_stars, bw_user_avatar, bw_tag, flag_user, bw_paginator) to keyword args; whitespace normalization.
templates/sounds/pack.html Update bw_user_avatar/bw_tag calls to keyword args; whitespace normalization.
templates/sounds/multiple_sounds_attribution.txt Whitespace normalization in {% if %} tag.
templates/sounds/modal_similar_sounds.html Update bw_paginator call to match new signature; whitespace normalization.
templates/sounds/modal_downloaders.html Update bw_paginator call to match new signature.
templates/sounds/edit_and_describe.html Whitespace normalization in control-flow template tags.
templates/sounds/display_sound.html Whitespace normalization; update bw_user_avatar usage to size=.
templates/sounds/display_pack.html Whitespace normalization; update bw_tag/bw_user_avatar calls to keyword args.
templates/search/search.html Update display_search_option and bw_paginator calls to keyword args; whitespace normalization.
templates/search/search_forum.html Whitespace normalization; update bw_paginator call.
templates/search/facet.html Update bw_tag usage to keyword args.
templates/monitor/moderation.html Whitespace normalization.
templates/monitor/base.html Whitespace normalization in {% if %} blocks.
templates/molecules/object_selector.html Update inclusion-tag calls to pass optional args by keyword (selected=, is_featured=).
templates/molecules/navbar_user_section.html Update bw_user_avatar to use size=.
templates/molecules/geotag_form_field.html Whitespace normalization in {% if %}.
templates/molecules/carousel.html Whitespace normalization.
templates/moderation/ticket.html Whitespace normalization in {% if %}.
templates/moderation/modal_tardy.html Update bw_paginator to use anchor=.
templates/moderation/modal_pending.html Update bw_paginator to use anchor=.
templates/moderation/modal_annotations.html Update bw_user_avatar to use size=.
templates/moderation/assigned.html Update bw_paginator to use anchor=; whitespace normalization.
templates/moderation/assign_sounds.html Update bw_user_avatar to use size=.
templates/messages/messages_list.html Update bw_paginator to use anchor=.
templates/messages/message.html Update bw_user_avatar to use size=; update flag_user to use keyword args.
templates/front.html Update bw_tag usage to keyword args.
templates/forum/threads.html Update bw_paginator to use anchor=.
templates/forum/thread.html Update bw_paginator to use anchor=.
templates/forum/reply.html Update bw_user_avatar to use size=.
templates/forum/new_thread.html Update bw_user_avatar to use size=.
templates/forum/hot_threads.html Update bw_paginator call to match new signature.
templates/forum/display_thread.html Update bw_user_avatar optional args to keyword form; whitespace normalization.
templates/forum/display_post.html Update bw_user_avatar to use size=; update flag_user to use keyword args.
templates/forum/display_forum.html Update bw_user_avatar to use size=.
templates/emails/email_stream.txt Normalize whitespace (incl. NBSP removal) in template tags.
templates/emails/email_notification_approved_but.txt Whitespace normalization in {% absurl %} call.
templates/donations/donation_list.html Whitespace normalization; update bw_paginator to use anchor=.
templates/collections/your_collections.html Whitespace normalization in {% block %} tags.
templates/collections/modal_add_sound_to_collection.html Whitespace normalization in {% if %} / {% for %}.
templates/collections/edit_collection.html Whitespace normalization in tag calls and conditionals.
templates/collections/display_collection.html Whitespace normalization in {% if %} within an attribute.
templates/collections/collection.html Update bw_user_avatar/bw_tag calls to keyword args.
templates/bookmarks/bookmarks.html Whitespace normalization; update bw_paginator to use anchor=.
templates/atoms/stars.html Whitespace normalization in bw_icon calls.
templates/accounts/modal_follow.html Update bw_paginator calls to match new signature; whitespace normalization.
templates/accounts/modal_downloads.html Update bw_paginator to use anchor=.
templates/accounts/modal_comments.html Update flag_user to use keyword args; update bw_paginator to use anchor=.
templates/accounts/manage_sounds.html Whitespace normalization; update bw_paginator and show_file to keyword args.
templates/accounts/edit.html Update bw_user_avatar to use size=.
templates/accounts/display_user.html Update bw_user_avatar to use size=; whitespace normalization in {% endif %}.
templates/accounts/charts.html Whitespace normalization in {% for %} loops.
templates/accounts/attribution.html Whitespace normalization; update bw_paginator to use anchor=; normalize absurl calls.
templates/accounts/admin_delete_confirmation.html Whitespace normalization in {% for %} loops.
templates/accounts/account.html Update bw_user_avatar/bw_tag to keyword args; whitespace normalization.
templates/accounts/account_settings_base.html Whitespace normalization in {% if %} blocks.
sounds/templatetags/display_sound.py Enforce keyword-only optional arg (is_featured) in inclusion tag signature.
sounds/templatetags/display_pack.py Enforce keyword-only optional arg (selected) in inclusion tag signature.
search/templatetags/search.py Enforce keyword-only optional arg (widget) in inclusion tag signature.
general/templatetags/tests.py Update paginator template-render test to use keyword args (anchor=).
general/templatetags/bw_templatetags.py Enforce keyword-only optional args for core UI template tags (bw_tag, bw_user_avatar, bw_sound_stars, bw_paginator).
DEVELOPERS.md Document the keyword-only optional-arg convention for template tags.
accounts/templatetags/flag_user.py Enforce keyword-only optional args (text, user_sounds) in inclusion tag signature.
accounts/templatetags/filefunctions.py Enforce keyword-only optional arg (non_recursive) in inclusion tag signature.
accounts/templatetags/display_user.py Enforce keyword-only optional arg (selected) in inclusion tag signature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread DEVELOPERS.md
@alastair
alastair force-pushed the templatetags-kwargs branch from 01bf07f to 5e4ed72 Compare July 10, 2026 09:27

@ffont ffont left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm both excited and frightened by this PR. Looks good on paper anyway :)

@alastair
alastair merged commit 97dbca2 into master Jul 13, 2026
2 checks passed
@alastair
alastair deleted the templatetags-kwargs branch July 13, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants