Phoenix full url using sigil_p
Phoenix team has created the new sigil_p macro to build url paths in the newest version (1.7.0). And today I learned that if you need to use the full path, let's say to use an image on an email, then you'd need to wrap the sigil_p
call on the url/1 function.
iex> ~p"/images/header.jpg"
# => "/images/header.jpg"
iex> url(~p"/images/header.jpg")
# => "http://localhost:4000/images/header.jpg"
Tweet