Escaping Link to

I am iterating over a @posts and my eex can display

<%= %>/users/<%= post.user.slug %>/posts/<%= post.slug %>


thats ok

but, when I put this long eex url in a simple href

<a href="<%= %>/users/niccolox/posts/<%= %>"><%= post.title %></a>

becomes (wrong)

I know can make custom Router Helpers, but is there a way to escape the href in eex ?

Look at the generated sources, there is no Your browser only augments it because your href is relative. Use a schema and it work as you expect.


No need to make your own custom router helpers, you can just use router helpers:

Router.Helpers.user_post_path(conn, :show, user_slug, post_slug)

Now this is assuming you have something like this setup in your routes:

resources "/users", UserController do
  resources "/posts", PostController

ok, thanks, adding the link schema i.e http fixed it


thanks, I had this already

I should of exposed more

I am adding a third host/domain arg for a multi site cross domain linking solution

I saw dailydrip do some vids on extending actions and routes for a 3rd arg or I could use the host in the router, but I am exploring Forward in router.ex

thanks for the time today