Router assistants are included in your controllers and view the web.ex file:
def controller do quote do use Phoenix.Controller ... import MyApp.Router.Helpers end end def view do quote do use Phoenix.View, root: "web/templates" ... import MyApp.Router.Helpers ... end end
As you can see, the controller and view functions import the MyApp.Router.Helpers module. Helper functions are defined here ( _path and url ).
You can use the full name:
Phoenix.Controller.redirect(to: TestAppRouter.Helpers.page_path(conn, :index))
Or you can import route helpers and just use page_path
import MyApp.Router.Helpers # or import MyApp.Router.Helpers, only: [page_path: 2]
However, if you then use the plug-in in the pipeline of your router, you will cause a circular dependency and your code will not compile.
Gazler
source share