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

implement Phoenix.HTML.Safe protocol #5

Merged
merged 3 commits into from
Jan 15, 2025

Conversation

hdahlheim
Copy link
Contributor

@hdahlheim hdahlheim commented Jan 13, 2025

Adds a struct for the PhoenixImportmap.Importmap module that implements the Phoenix.HTML.Safe protocol discussed in #4.

By using the protocol, we signal to the user that the return value of PhoenixImportmap.importmap/1 is safe to inject into the template.

Changes made in this PR

  • Adds :phoenix_html as a dependency.
  • Adds a struct to the PhoenixImportmap.Importmap module.
  • Derives Jason.Encoder for %PhoenixImportmap.Importmap{}.
  • Removes Importmap.json/1 from PhoenixImportmap.importmap/1.
  • Updates the test for PhoenixImportmap.importmap/1 to check for safe serialization.
  • Updates relevant documentation to reflect these changes.

This change is a breaking change if you currently use raw to interpolate the importmap into the template.

Let me know if these changes look good to you.

@gilest gilest added the enhancement New feature or request label Jan 14, 2025
Copy link
Owner

@gilest gilest left a comment

Choose a reason for hiding this comment

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

Looks great, and CI passes ✅

If you could please correct the doc typo I think we can merge and release.

For now I'll create a manual changelog since I don't have release automation set up yet

lib/phoenix_importmap.ex Outdated Show resolved Hide resolved
Co-authored-by: Giles Thompson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants