Routex.Utils (Routex v1.2.2)

View Source

Provides an interface to functions which can be used in extensions.

Summary

Functions

Prints an alert. Should be used when printing critical alerts in the terminal during compile time.

Returns the module to use for LiveView assignments

Backward compatible version of Code.ensure_compiled!/1

Test env aware variant of Module.get_attribute. Delegates to Module.get_attribute/3 in non-test environments. In test environment it returns the result of Module.get_attribute/3 or an empty list when the module is already compiled.

Returns the AST to get the current branch from process dict or from assigns, conn or socket based on the available variables in the caller module.

Prints an indented text. Should be used when printing messages in the terminal during compile time.

Functions

alert(title \\ "Critical", input)

Prints an alert. Should be used when printing critical alerts in the terminal during compile time.

assign_module()

@spec assign_module() :: module()

Returns the module to use for LiveView assignments

ensure_compiled!(mod)

@spec ensure_compiled!(module()) :: module()

Backward compatible version of Code.ensure_compiled!/1

get_attribute(module, key, default \\ nil)

Test env aware variant of Module.get_attribute. Delegates to Module.get_attribute/3 in non-test environments. In test environment it returns the result of Module.get_attribute/3 or an empty list when the module is already compiled.

get_branch(arg1)

@spec get_branch(Routex.Types.route() | map() | Plug.Conn.t() | Phoenix.Socket.t()) ::
  integer()

get_helper_ast(caller)

@spec get_helper_ast(caller :: Routex.Types.env()) :: Routex.Types.ast()

Returns the AST to get the current branch from process dict or from assigns, conn or socket based on the available variables in the caller module.

print(module \\ nil, input)

@spec print(module(), input :: iodata()) :: :ok

Prints an indented text. Should be used when printing messages in the terminal during compile time.