-
Notifications
You must be signed in to change notification settings - Fork 409
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
Add maybeField #311
base: master
Are you sure you want to change the base?
Add maybeField #311
Conversation
Wouldn't it be better to have a function like returnFromMaybe value = maybe empty pure value
maybeField key value = field key $ returnFromMaybe <=< value
maybeField' key value = field' key $ returnFromMaybe <=< value |
This field allows to easily introduce optional keys which can then be conditionally rendered in templates.
This is a very nice suggestion, thanks! Nice enough to not even bother with |
Right, I usually inline |
Since boolField :: String -> (Item a -> Bool) -> Context a
boolField name f = field name (\i -> if f i then pure undefined else empty) or its monadic version. |
I can see how that is useful but we'd rather have a descriptive error than |
Sure, improve it, it's just a proof of concept I picked up using. It may even be the wrong solution: we have |
This field allows to easily introduce optional keys which can then be conditionally rendered in templates.
This is pretty useless for
ListField
(empty list is nullish) therefore I exported only String variant.