Skip to content

What does :namespace do when invoked with use in *_web.ex? #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
toraritte opened this issue Jun 23, 2018 · 1 comment
Open

What does :namespace do when invoked with use in *_web.ex? #22

toraritte opened this issue Jun 23, 2018 · 1 comment

Comments

@toraritte
Copy link
Owner

For example:

  def controller do
    quote do
      use Phoenix.Controller, namespace: RumWeb
      import Plug.Conn
      import RumWeb.Router.Helpers
      import RumWeb.Gettext
    end
  end

  def view do
    quote do
      use Phoenix.View, root: "lib/rum_web/templates",
                        namespace: RumWeb

      # Import convenience functions from controllers
      import Phoenix.Controller, only: [get_flash: 2, view_module: 1]

      # Use all HTML functionality (forms, tags, etc)
      use Phoenix.HTML

      import RumWeb.Router.Helpers
      import RumWeb.ErrorHelpers
      import RumWeb.Gettext
    end
  end

Tried to follow it but it needs more time to figure it out.

@toraritte
Copy link
Owner Author

From the Phoenix.Controller documentation:

Options

When used, the controller supports the following options:

  • :namespace - sets the namespace to properly inflect the layout view. By default it uses the base alias in your controller name

  • :log - the level to log. When false, disables controller logging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant