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

Document having curly braces text literals in heex #3554

Merged
merged 2 commits into from
Dec 5, 2024

Conversation

LostKobrakai
Copy link
Contributor

@LostKobrakai LostKobrakai commented Dec 5, 2024

Contents curtesy of @SteffenDE having posted those on slack

@SteffenDE
Copy link
Collaborator

btw, there's also a warning if you try to do {"{"}:

== Compilation error in file lib/dev_app_web/components/layouts.ex ==
** (Phoenix.LiveView.Tokenizer.ParseError) lib/dev_app_web/components/layouts/root.html.heex:17:5: expected closing `}` for expression

In case you don't want `{` to begin a new interpolation, you may write it using `&lbrace;` or using `<%= "{" %>`
   |
14 |   <body class="bg-white">
15 |     {@inner_content}
16 |     <%= "{" %>
17 |     {"{"}
   |     ^
    (phoenix_live_view 1.0.0) lib/phoenix_live_view/tokenizer.ex:743: Phoenix.LiveView.Tokenizer.raise_syntax_error!/3
    (phoenix_live_view 1.0.0) lib/phoenix_live_view/tag_engine.ex:300: Phoenix.LiveView.TagEngine.handle_text/3
    (eex 1.18.0-dev) lib/eex/compiler.ex:331: EEx.Compiler.generate_buffer/4
    (phoenix_live_view 1.0.0) expanding macro: Phoenix.LiveView.HTMLEngine.compile/1
    lib/dev_app_web/components/layouts/root.html.heex: DevAppWeb.Layouts.root/1

@SteffenDE SteffenDE merged commit e8507cc into phoenixframework:main Dec 5, 2024
7 checks passed
@SteffenDE
Copy link
Collaborator

Thank you! 🙌🏻

Munksgaard added a commit to Munksgaard/live_select that referenced this pull request Dec 6, 2024
LiveView 1.0 adds support for interpolation using curly braces (`{...}`) instead
of angle brackets (`<%= ... %>`)[0]. This caused a compilation error in
ShowcaseLive, because we return literal curly braces in the HTML. The fix is to
either use `&lbrace;` or `<%= "{" %>`[1]. I think the former is nicer, so that's
what I've done here. If you disagree, I'm happy to change it.

I've also some instances of `live_flash/2` to `Phoenix.Flash.get/2`, as
`live_flash/2` is now deprecated[2]

0: https://hexdocs.pm/phoenix_live_view/Phoenix.Component.html#sigil_H/2-interpolation

1: phoenixframework/phoenix_live_view#3554

2: https://hexdocs.pm/phoenix_live_view/changelog.html#deprecations-1
Munksgaard added a commit to Munksgaard/live_select that referenced this pull request Dec 6, 2024
LiveView 1.0 adds support for interpolation using curly braces (`{...}`) instead
of angle brackets (`<%= ... %>`)[0]. This caused a compilation error in
`ShowcaseLive`, because we return literal curly braces in the HTML. The fix is to
either use `&lbrace;` or `<%= "{" %>`[1]. I think the former is nicer, so that's
what I've done here. If you disagree, I'm happy to change it.

I've also changed some instances of `live_flash/2` to `Phoenix.Flash.get/2`, as
`live_flash/2` is now deprecated[2]

0: https://hexdocs.pm/phoenix_live_view/Phoenix.Component.html#sigil_H/2-interpolation

1: phoenixframework/phoenix_live_view#3554

2: https://hexdocs.pm/phoenix_live_view/changelog.html#deprecations-1
Munksgaard added a commit to Munksgaard/live_select that referenced this pull request Dec 6, 2024
LiveView 1.0 adds support for interpolation using curly braces (`{...}`) instead
of angle brackets (`<%= ... %>`)[0]. This caused a compilation error in
`ShowcaseLive`, because we return literal curly braces in the HTML. The fix is to
either use `&lbrace;` or `<%= "{" %>`[1]. I think the former is nicer, so that's
what I've done here. If you disagree, I'm happy to change it.

I've also changed some instances of `live_flash/2` to `Phoenix.Flash.get/2`, as
`live_flash/2` is now deprecated[2]

Fixes: maxmarcon#88

0: https://hexdocs.pm/phoenix_live_view/Phoenix.Component.html#sigil_H/2-interpolation

1: phoenixframework/phoenix_live_view#3554

2: https://hexdocs.pm/phoenix_live_view/changelog.html#deprecations-1
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.

2 participants