boxed / django-fastdev

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

Suggestions for template variables using the `|default` filter #30

Open wgordon17 opened 1 year ago

wgordon17 commented 1 year ago

I have a whole bunch of templates that rely on the "empty resolves to false" behavior. Specifically setting some HTML class attribute defaults

class="{{height|default:'h-5'}} {{width|default:'w-5'}} {{color|default:'text-blue-500'}}"

Just wondering if you have any suggestions on

I like the other protections from gotchas that fastdev provides, just this one little nuance that has me disabling it for now 😞

boxed commented 1 year ago

I suggest always send those variables to the template. Presumably as None.