View Source Igniter.Libs.Phoenix (igniter v0.4.8)

Codemods & utilities for working with Phoenix

Summary

Functions

Adds a pipeline to a Phoenix router.

Adds a scope to a Phoenix router.

Appends code to a Phoenix router pipeline.

Appends to a phoenix router scope.

Returns true if the module is a Phoenix controller

Gets the list of endpoints that use a given router

Returns true if the module is a Phoenix HTML module

Lists all routers found in the project.

Moves to the use statement in a module that matches use TheirWebModule, :router

Selects a router to be used in a later step. If only one router is found, it will be selected automatically.

Returns the web module name for the current app

web_module_name() deprecated

Returns the web module name for the current app

Generates a module name that lives in the Web directory of the current app.

Generates a module name that lives in the Web directory of the current app.

Functions

add_pipeline(igniter, name, contents, opts \\ [])

@spec add_pipeline(Igniter.t(), atom(), String.t(), Keyword.t()) :: Igniter.t()

Adds a pipeline to a Phoenix router.

Options

  • :router - The router module to append to. Will be looked up if not provided.
  • :arg2 - The second argument to the scope macro. Must be a value (typically a module).

add_scope(igniter, route, contents, opts \\ [])

@spec add_scope(Igniter.t(), String.t(), String.t(), Keyword.t()) :: Igniter.t()

Adds a scope to a Phoenix router.

Options

  • :router - The router module to append to. Will be looked up if not provided.
  • :arg2 - The second argument to the scope macro. Must be a value (typically a module).

append_to_pipeline(igniter, name, contents, opts \\ [])

@spec append_to_pipeline(Igniter.t(), atom(), String.t(), Keyword.t()) :: Igniter.t()

Appends code to a Phoenix router pipeline.

Options

  • :router - The router module to append to. Will be looked up if not provided.

append_to_scope(igniter, route, contents, opts \\ [])

@spec append_to_scope(Igniter.t(), String.t(), String.t(), Keyword.t()) :: Igniter.t()

Appends to a phoenix router scope.

Relatively limited currently only exact matches of a top level route, second argument, and pipelines.

Options

  • :router - The router module to append to. Will be looked up if not provided.
  • :arg2 - The second argument to the scope macro. Must be a value (typically a module).
  • :with_pipelines - A list of pipelines that the pipeline must be using to be considered a match.

controller?(igniter, module)

@spec controller?(Igniter.t(), module()) :: boolean()

Returns true if the module is a Phoenix controller

endpoints_for_router(igniter, router)

@spec endpoints_for_router(igniter :: Igniter.t(), router :: module()) ::
  {Igniter.t(), [module()]}

Gets the list of endpoints that use a given router

html?(igniter, module)

@spec html?(Igniter.t(), module()) :: boolean()

Returns true if the module is a Phoenix HTML module

list_routers(igniter)

@spec list_routers(Igniter.t()) :: {Igniter.t(), [module()]}

Lists all routers found in the project.

move_to_router_use(igniter, zipper)

@spec move_to_router_use(Igniter.t(), Sourceror.Zipper.t()) ::
  :error | {:ok, Sourceror.Zipper.t()}

Moves to the use statement in a module that matches use TheirWebModule, :router

select_router(igniter, label \\ "Which router should be modified?")

@spec select_router(Igniter.t(), String.t()) :: {Igniter.t(), module() | nil}

Selects a router to be used in a later step. If only one router is found, it will be selected automatically.

If no routers exist, {igniter, nil} is returned.

If multiple routes are found, the user is prompted to select one of them.

web_module(igniter)

@spec web_module(Igniter.t()) :: module()

Returns the web module name for the current app

web_module_name()

This function is deprecated. Use `web_module/0` instead..
@spec web_module_name() :: module()

Returns the web module name for the current app

web_module_name(suffix)

This function is deprecated. Use `web_module_name/2` instead..
@spec web_module_name(String.t()) :: module()

Generates a module name that lives in the Web directory of the current app.

web_module_name(igniter, suffix)

@spec web_module_name(Igniter.t(), String.t()) :: module()

Generates a module name that lives in the Web directory of the current app.