Skip to content

Commit

Permalink
Bump live_view to 1.0
Browse files Browse the repository at this point in the history
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: #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
  • Loading branch information
Munksgaard committed Dec 6, 2024
1 parent b2707dd commit 129f7bd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
8 changes: 4 additions & 4 deletions lib/support/live_select_web/components/layouts/app.html.heex
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<main class="container mx-auto">
<%= if live_flash(@flash, :info) do %>
<%= if Phoenix.Flash.get(@flash, :info) do %>
<p class="alert alert-info" role="alert" phx-click="lv:clear-flash" phx-value-key="info">
<%= live_flash(@flash, :info) %>
<%= Phoenix.Flash.get(@flash, :info) %>
</p>
<% end %>

<%= if live_flash(@flash, :error) do %>
<%= if Phoenix.Flash.get(@flash, :error) do %>
<p class="alert alert-error" role="alert" phx-click="lv:clear-flash" phx-value-key="error">
<%= live_flash(@flash, :error) %>
<%= Phoenix.Flash.get(@flash, :error) %>
</p>
<% end %>

Expand Down
4 changes: 2 additions & 2 deletions lib/support/live_select_web/live/showcase_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ defmodule LiveSelectWeb.ShowcaseLive do
~H"""
<div>
<span class="text-success">&lt;.live_select</span>
<br />&nbsp;&nbsp; <span class="text-success">field</span>=<span class="text-info">{my_form[:city_search]}</span>
<br />&nbsp;&nbsp; <span class="text-success">field</span>=<span class="text-info">&lbrace;@my_form[:city_search]&rbrace;</span>
<%= for {key, value} <- @opts, !is_nil(value) do %>
<%= if value == true do %>
<br />&nbsp;&nbsp; <span class="text-success"><%= key %></span>
<br />&nbsp;&nbsp; <span class="text-success">{key}</span>
<% else %>
<br />&nbsp;&nbsp; <span class="text-success"><%= key %></span>=<span class="text-info"><%= @format_value.(value) %></span>
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ defmodule LiveSelect.MixProject do
# Type `mix help deps` for examples and options.
defp deps do
[
{:phoenix_live_view, "~> 0.19"},
{:phoenix_live_view, "~> 1.0"},
{:phoenix_html, "~> 4.0"},
{:phoenix_html_helpers, "~> 1.0"},
{:jason, "~> 1.0"},
{:phoenix, ">= 1.6.0", optional: true},
{:phoenix_live_reload, "~> 1.2", only: :dev},
{:phoenix_ecto, "~> 4.0", only: [:dev, :test, :demo]},
{:ecto, "~> 3.8"},
{:floki, ">= 0.30.0", only: :test},
{:floki, ">= 0.37.0", only: :test},
{:esbuild, "~> 0.4", only: [:dev, :test, :demo]},
{:plug_cowboy, "~> 2.5", only: [:dev, :demo]},
{:faker, "~> 0.17", only: [:dev, :test]},
Expand Down
Loading

0 comments on commit 129f7bd

Please sign in to comment.