diff --git a/lib/pinchflat/utils/string_utils.ex b/lib/pinchflat/utils/string_utils.ex index d96d6c10..bee23b50 100644 --- a/lib/pinchflat/utils/string_utils.ex +++ b/lib/pinchflat/utils/string_utils.ex @@ -41,4 +41,15 @@ defmodule Pinchflat.Utils.StringUtils do string end end + + @doc """ + Wraps a string in double braces. Useful as a UI helper now that + LiveView 1.0.0 allows `{}` for interpolation so now we can't use braces + directly in the view. + + Returns binary() + """ + def double_brace(string) do + "{{ #{string} }}" + end end diff --git a/lib/pinchflat_web.ex b/lib/pinchflat_web.ex index ef58d005..28d58077 100644 --- a/lib/pinchflat_web.ex +++ b/lib/pinchflat_web.ex @@ -100,6 +100,7 @@ defmodule PinchflatWeb do import PinchflatWeb.CustomComponents.TextComponents import PinchflatWeb.CustomComponents.TableComponents import PinchflatWeb.CustomComponents.ButtonComponents + import Pinchflat.Utils.StringUtils, only: [double_brace: 1] alias Pinchflat.Settings alias Pinchflat.Utils.StringUtils diff --git a/lib/pinchflat_web/components/core_components.ex b/lib/pinchflat_web/components/core_components.ex index 8f5ff759..e66e236f 100644 --- a/lib/pinchflat_web/components/core_components.ex +++ b/lib/pinchflat_web/components/core_components.ex @@ -82,7 +82,7 @@ defmodule PinchflatWeb.CoreComponents do
- <%= render_slot(@inner_block) %> + {render_slot(@inner_block)}
@@ -126,9 +126,9 @@ defmodule PinchflatWeb.CoreComponents do ]}>
- <%= @title %> + {@title}
-

<%= msg %>

+

{msg}