Add class-level customization and visibility control for TemplateHooks.

Review Request #14556 — Created Aug. 6, 2025 and submitted — Latest diff uploaded

Information

Djblets
release-5.x

Reviewers

TemplateHook has always required name, template_name, apply_to,
and extra_context to be passed into __init__(), even in a subclass.
This makes usage a bit verbose.

This change adds new class-level control of these options. Now, a
subclass can define these as class attributes and they'll be used if the
caller doesn't override any of them with a parameter.

Subclasses can also opt out of rendering by overriding
should_render(), which means they no longer need to handle this in a
template.

Unit tests pass.

Tested this with the banner component work in Review Board, utilizing
the new features.

Commits

Files