Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. defmodule PhxAppWeb do
  2. @moduledoc """
  3. The entrypoint for defining your web interface, such
  4. as controllers, views, channels and so on.
  5.  
  6. This can be used in your application as:
  7.  
  8. use PhxAppWeb, :controller
  9. use PhxAppWeb, :view
  10.  
  11. The definitions below will be executed for every view,
  12. controller, etc, so keep them short and clean, focused
  13. on imports, uses and aliases.
  14.  
  15. Do NOT define functions inside the quoted expressions
  16. below. Instead, define any helper function in modules
  17. and import those modules here.
  18. """
  19.  
  20. def controller do
  21. quote do
  22. use Phoenix.Controller, namespace: PhxAppWeb
  23.  
  24. import Plug.Conn
  25. import PhxAppWeb.Gettext
  26. alias PhxAppWeb.Router.Helpers, as: Routes
  27. end
  28. end
  29.  
  30. def view do
  31. quote do
  32. use Phoenix.View,
  33. root: "lib/phx_app_web/templates",
  34. namespace: PhxAppWeb
  35.  
  36. # Import convenience functions from controllers
  37. import Phoenix.Controller, only: [get_flash: 1, get_flash: 2, view_module: 1]
  38.  
  39. # Use all HTML functionality (forms, tags, etc)
  40. use Phoenix.HTML
  41.  
  42. import PhxAppWeb.ErrorHelpers
  43. import PhxAppWeb.Gettext
  44. alias PhxAppWeb.Router.Helpers, as: Routes
  45. end
  46. end
  47.  
  48. def router do
  49. quote do
  50. use Phoenix.Router
  51. import Plug.Conn
  52. import Phoenix.Controller
  53. end
  54. end
  55.  
  56. def channel do
  57. quote do
  58. use Phoenix.Channel
  59. import PhxAppWeb.Gettext
  60. end
  61. end
  62.  
  63. @doc """
  64. When used, dispatch to the appropriate controller/view/etc.
  65. """
  66. defmacro __using__(which) when is_atom(which) do
  67. apply(__MODULE__, which, [])
  68. end
  69. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement