π More adventures and pushing the boundaries of vanilla Django
π https://softwarecrafts.co.uk/100-words/day-298
#100_words,#django,#partials,#templates
I was wondering if there had been any progress on the state of HTML includes, and sure enough @mxbck has written about just that not too long ago.
Weekend #Python tip: #partials
Do you have a function that sometimes requires an extra argument and sometimes it doesn't? And passing that extra argument requires you to do lots of if-else around your code?
You can create a "shortcut" to a function with a certain set of args:
def do(what, urgent=False):
print("doing", what, "now" if urgent else "later")
do("chores")
# doing chores later
chopchop = functools.partial(do, urgent=True)
chopchop("chores")
# doing chores now
Episode #388 - Strict Locals
Ruby on Rails 7.1 introduces Required Template Arguments w/ Default Values, or Strict Locals. This solves the issue of difficult to reason about dependencies & runtime compilations. In this episode, we look at how Strict Locals can improve the overall maintainability of our Rails partials.