I’ll leave some tests that I did below.
Test 1
<button phx-click="test" phx-value-myvar="<% result %>" phx-throttle="1000">Button Test</button>
%{"myvar" => "", "value" => ""}
Does not return any value,
returns the following warning
warning: variable result in code block has no effect as it is never returned (remove the variable or assign it to _ to avoid warnings)
lib/project_web/live/example_live/index.html.leex:48: ProjectWeb.MatrixPriorityLive.Index.render/1
Test 2
When I put it that way
<button phx-click="test" phx-value-myvar="My Variable test" phx-throttle="1000">Button Test</button>
%{"myvar" => "My Variable test", "value" => ""}
I manage to have variable return successfully.
Test 3
<button phx-click="test" phx-value-myvar="<%= result %>" phx-throttle="1000">Button Test</button>
When I add the “=” it returns the following error.
(exit) an exception was raised:
** (ArgumentError) argument error
:erlang.apply([%{example1: “1”, example2: “Result End 1”, example3: 1, example4: “Critical”}, %{example1: “1”, example2: “Result End 2”, example3: 1, example4: “Low”}, %{example1: “1”, example2: “Result End 3”, example3: 1, example4: “Critical”}], :clause, )
(project 0.1.0) lib/project_web/live/example_live/index.html.leex:48: anonymous fn/3 in ProjectWeb.ExampleLive.Index.render/1
(elixir 1.11.2) lib/enum.ex:2181: Enum.“-reduce/3-lists^foldl/2-0-”/3
(project 0.1.0) lib/project_web/live/example_live/index.html.leex:41: anonymous fn/2 in ProjectWeb.ExampleLive.Index.render/1
(phoenix_live_view 0.15.7) lib/phoenix_live_view/diff.ex:356: Phoenix.LiveView.Diff.traverse/6
(phoenix_live_view 0.15.7) lib/phoenix_live_view/diff.ex:430: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/6
(elixir 1.11.2) lib/enum.ex:2181: Enum.“-reduce/3-lists^foldl/2-0-”/3
(phoenix_live_view 0.15.7) lib/phoenix_live_view/diff.ex:356: Phoenix.LiveView.Diff.traverse/6
(phoenix_live_view 0.15.7) lib/phoenix_live_view/diff.ex:430: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/6
(elixir 1.11.2) lib/enum.ex:2181: Enum.“-reduce/3-lists^foldl/2-0-”/3
(phoenix_live_view 0.15.7) lib/phoenix_live_view/diff.ex:356: Phoenix.LiveView.Diff.traverse/6
(phoenix_live_view 0.15.7) lib/phoenix_live_view/diff.ex:130: Phoenix.LiveView.Diff.render/3
(phoenix_live_view 0.15.7) lib/phoenix_live_view/static.ex:298: Phoenix.LiveView.Static.to_rendered_content_tag/4
(phoenix_live_view 0.15.7) lib/phoenix_live_view/static.ex:149: Phoenix.LiveView.Static.render/3
(phoenix_live_view 0.15.7) lib/phoenix_live_view/controller.ex:35: Phoenix.LiveView.Controller.live_render/3
(phoenix 1.5.7) lib/phoenix/router.ex:352: Phoenix.Router.call/2
(project 0.1.0) lib/project_web/endpoint.ex:1: ProjectWeb.Endpoint.plug_builder_call/2
(project 0.1.0) lib/plug/debugger.ex:136: ProjectWeb.Endpoint.“call (overridable 3)”/2
(project 0.1.0) lib/project_web/endpoint.ex:1: ProjectWeb.Endpoint.call/2
(phoenix 1.5.7) lib/phoenix/endpoint/cowboy2_handler.ex:65: Phoenix.Endpoint.Cowboy2Handler.init/4
Test 4
<button phx-click="test" phx-value-myvar="<%= result.example2 %>" phx-throttle="1000">Button Test</button>
(exit) an exception was raised:
** (ArgumentError) argument error
:erlang.apply([%{example1: “1”, example2: “Result End 1”, example3: 1, example4: “Critical”}, %{example1: “1”, example2: “Result End 2”, example3: 1, example4: “Low”}, %{example1: “1”, example2: “Result End 3”, example3: 1, example4: “Critical”}], :clause, )
(project 0.1.0) lib/project_web/live/example_live/index.html.leex:48: anonymous fn/3 in ProjectWeb.ExampleLive.Index.render/1
(elixir 1.11.2) lib/enum.ex:2181: Enum.“-reduce/3-lists^foldl/2-0-”/3
(project 0.1.0) lib/project_web/live/example_live/index.html.leex:41: anonymous fn/2 in ProjectWeb.ExampleLive.Index.render/1
(phoenix_live_view 0.15.7) lib/phoenix_live_view/diff.ex:356: Phoenix.LiveView.Diff.traverse/6
(phoenix_live_view 0.15.7) lib/phoenix_live_view/diff.ex:430: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/6
(elixir 1.11.2) lib/enum.ex:2181: Enum.“-reduce/3-lists^foldl/2-0-”/3
(phoenix_live_view 0.15.7) lib/phoenix_live_view/diff.ex:356: Phoenix.LiveView.Diff.traverse/6
(phoenix_live_view 0.15.7) lib/phoenix_live_view/diff.ex:430: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/6
(elixir 1.11.2) lib/enum.ex:2181: Enum.“-reduce/3-lists^foldl/2-0-”/3
(phoenix_live_view 0.15.7) lib/phoenix_live_view/diff.ex:356: Phoenix.LiveView.Diff.traverse/6
(phoenix_live_view 0.15.7) lib/phoenix_live_view/diff.ex:130: Phoenix.LiveView.Diff.render/3
(phoenix_live_view 0.15.7) lib/phoenix_live_view/static.ex:298: Phoenix.LiveView.Static.to_rendered_content_tag/4
(phoenix_live_view 0.15.7) lib/phoenix_live_view/static.ex:149: Phoenix.LiveView.Static.render/3
(phoenix_live_view 0.15.7) lib/phoenix_live_view/controller.ex:35: Phoenix.LiveView.Controller.live_render/3
(phoenix 1.5.7