boxed / django-fastdev

An app to make it safer, faster and more fun to develop in Django
BSD 3-Clause "New" or "Revised" License
156 stars 13 forks source link

Feature Request: setting to ignore templates within specific directories #40

Closed geoffbeier closed 4 months ago

geoffbeier commented 4 months ago

I'm using django-allauth-ui and just enabled django-fastdev for the first time. It has been helpful and smooth for the most part. In order to avoid sending tailwind css twice in every allauth-ui template while still using my custom daisyui theme, I needed to copy the allauth-ui templates into my project.

django-allauth-ui uses slippers components internally. A common pattern for those components is:

{% var render_fields=render_fields|default:"true" %}

When I first saw the error, I tried writing a context processor that would set those variables that get caught in this check to None by default, as described in a reply on issue #30. Slippers doesn't pass context through to the components by default, though, so that's not a fix.

And fixing the "vendored" templates to explicitly pass a None every time this pattern appears is going to slow me down when it comes time to update to the next release of django-allauth-ui. Given their release cadence, I'd like very much to avoid merge headaches.

I think what I'd really like to do is ignore everything in the components directory of the templates tree I copied in from django-allauth-ui.

I believe a relatively easy way to do this would be adding a FASTDEV_IGNORED_TEMPLATES setting which defaults to an empty list and just returns orig_resolve(self,context) from resolve_override() if one of the expressions on that list matches the current template.

I'd be happy to put together a PR and submit it if this seems useful.

boxed commented 4 months ago

Yea that would be great!