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

Add jsAttributesHandler #1622

Merged
merged 3 commits into from
Aug 26, 2019
Merged

Add jsAttributesHandler #1622

merged 3 commits into from
Aug 26, 2019

Conversation

jezen
Copy link
Member

@jezen jezen commented Aug 23, 2019

This adds jsAttributesHandler to run arbitrary Handler code before building the attributes map for the script tag generated by widgetFile. This is useful if you need to add a randomised nonce value to that tag.

Closes #1621

Before submitting your PR, check that you've:

After submitting your PR:

  • Update the Changelog.md file with a link to your PR
  • Check that CI passes (or if it fails, for reasons unrelated to your change, like CI timeouts)

@jezen jezen requested a review from snoyberg August 23, 2019 11:59
This adds `jsAttributesHandler` to run arbitrary Handler code before
building the attributes map for the script tag generated by `widgetFile`.
This is useful if you need to add a randomised nonce value to that tag.

Closes #1621
--
-- @since 1.6.16
jsAttributesHandler :: HandlerFor site [(Text, Text)]
jsAttributesHandler = getYesod >>= return . jsAttributes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can also be written as jsAttributes <$> getYesod, but there difference isn't that improtant.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to make that change, and also some more hlint-driven cleanup along the way.

@snoyberg snoyberg merged commit 50a3242 into yesodweb:master Aug 26, 2019
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

Successfully merging this pull request may close these issues.

Dynamic jsAttributes
2 participants