MasoniteFramework / masonite

The Modern And Developer Centric Python Web Framework. Be sure to read the documentation and join the Discord channel for questions: https://discord.gg/TwKeFahmPZ

Home Page:http://docs.masoniteproject.com

Repository from Github https://github.comMasoniteFramework/masoniteRepository from Github https://github.comMasoniteFramework/masonite

Old helper is missing the default value parameter

tpow opened this issue · comments

Describe the bug

While trying to upgrade a project from Masonite v3 to v4 I noticed that the "old" helper no longer has the default value option. This makes it awkward to use in certain cases and is an unnecessary upgrade pain point.

It looks like it would be easy to implement. Something like this should work In sessions/helpers.py:

def old(key: str, default="") -> str:                                                                
      """Helper used to get value from session for the given key."""               
      return Session.get(key) or default

Alternatively, I might be able to use a construct like this in the templates, but I am not sure that will work correctly and makes the template somewhat confusing:

<input value="{{ old('amount') or '0.0' }}">

Expected behaviour

No response

Steps to reproduce the bug

No response

Screenshots

No response

OS

Linux

OS version

Ubuntu LTS

Browser

Safari 16

Masonite Version

4.17.4

Anything else ?

No response