Remove slippers#1194
Draft
rebkwok wants to merge 5 commits into
Draft
Conversation
Slippers stops working under Django 6.0 (variable names can no longer contain
hyphens, which breaks Slippers' {% attrs %} tag) and pulling in a workaround
just to keep a vendored library alive isn't worth it. Drop Slippers entirely
and provide the small subset of functionality we actually use as a custom
template tag library.
New template builtins (airlock/templatetags/template_components.py):
- {% component "path.html" with key=value ... %}body{% endcomponent %}
replaces the {% #component %}...{% /component %} block syntax. The inner
content is rendered once and stashed under a sentinel context key; the
component template renders it via {% body %}. {% body %} reads only the
topmost context dict so an outer component's body never leaks into a
nested {% include %} that doesn't push its own body.
- {% attrs name1 name2 name3=expr %} replaces Slippers' attrs tag, looking
up positional args in the include's pushed extra_context only. Without
this restriction, outer-scope variables like a Django Form bound to
`form` would leak in and end up rendered as HTML attributes.
- {% setvar name=value %} replaces Slippers' {% var %} tag.
- {% fragment as varname %}...{% endfragment %} captures rendered HTML into
a named variable, for callers that need to pass HTML through a kwarg
(e.g. a card's custom_button slot).
The {% component %} tag is the main simplification: with it, callers no
longer need to declare uniquely-named {% partialdef %} blocks and reference
them by hard-coded "template_path.html#partial_name" strings, and component
templates no longer need a setvar-based prelude to stop the partial-name
string from leaking down into nested includes. The `label` parameter on
button/code/list-group-item is gone too — the body slot replaces it.
Settings:
- Drop "slippers" from INSTALLED_APPS.
- Drop the slippers + airlock_components template builtins; add the new
template_components builtin.
- Update MissingVariableErrorFilter to walk the exception traceback for the
actual template name. In Django 6.0 context.template_name is the top-level
template, so the existing _components/_partials prefix check missed
included templates entirely.
Pyproject:
- Drop slippers dependency and the exclude_blocks coverage workaround.
Multi-slot components (card, modal) keep a small {% setvar local_X=X %} +
{% setvar X="" %} prelude for their non-body slot variables (custom_button,
button), since those are still passed as ordinary kwargs and would otherwise
inherit from outer context.
Deletions (unused vendor code from the original job-server import):
- assets.views / assets.base_views / assets.test_components and the
/ui-components/ gallery URL.
- Unused upstream component templates: gallery, header, footer, breadcrumbs,
multiselect, skip-link, grid, timeline-item, time, log-item, table/*,
pill/{application,project}-status, form/{fieldset,legend}.
- Unused partials: card-pagination, latest-job-requests-table, staff-hero.
- assets/templates/components.yaml and airlock/templatetags/airlock_components.py.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An experiment, don't merge this