Add a variable in link helper

So I have this in my index.html.eex:

<%= render MyresumeWeb.PageView, "section_text.html", text: "some text here", route: "/hobbies" %>

and in my section_text.html.eex:

<%= link("Read more", to: @route, class: "button is-medium is-info") %>

I get the following error:

assign @route not available in eex template.

how can I use the @route variable from my render method in my link helper ?

OK found the solution. just put my variable in a map.

<%= render MyresumeWeb.PageView, "section_text.html", %{text: "some text here", route: "/hobbies"} %>

1 Like