Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullable type used for attribute value could omit the attribute if value.isNull #28

Open
schveiguy opened this issue Jun 16, 2017 · 0 comments

Comments

@schveiguy
Copy link
Contributor

I currently have some types that have nullable values that come from a database.

Let's say it's an id that's either null or not.

Nullable!int othertable_id;

If I want to display an editor to this id, I can do this in diet:

input(type='number', value=othertable_id)

The resulting html code shows value="Nullable.null", which works OK for this integer, but is a bit messy (and technically be interpreted as text in some browsers).

Because there isn't a type that evaluates to false or some value, it's hard to do this in one statement. For example:

input(type='number', value=(othertable_id.isNull ? false : othtertable_id)) // error

However, a nice addition to diet would be to treat a Nullable value that is null as a "false" in terms of erasing the attribute. I don't think this should impact existing code, since you likely have to sanitize something like this with if statements.

I think this can come in handy in a lot of places, since html has many spots where the absence of an attribute means something different than the presence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant