The docs are not consistent regarding variable assignment inside live templates.
This one says:
To sum up:
- Avoid passing block expressions to library and custom functions
- Never do anything on
def render(assigns)
besides rendering a template or invoking the~L
sigil- Avoid defining local variables, except within
for
,case
, and friends
And this one literally suggests defining a local variable just like you did:
<%= f = form_for @changeset, "#" %>
<%= live_component @socket, SomeComponent, f: f %>
</form>
Only a few days ago I posted this question about the same subject.
I don’t know exactly what is the rationale or the right thing to do.