Aurora.Uix.Templates.Basic.ModulesGenerator (Aurora UIX v0.1.0)

Dynamic LiveView module generator for creating CRUD-oriented user interfaces.

Transforms configuration maps into fully-functional, dynamically generated LiveView modules for index, show, and form UI components. Generates modules with event handling, form validation, and flexible rendering. All code generation is performed at compile time.

Delegates actual code generation to specialized sub-generators: FormGenerator, IndexGenerator, and ShowGenerator.

Summary

Functions

Generates a LiveView module for the specified UI component type.

Returns the handler module or the default one.

Generates a module name by concatenating the caller, module name, and suffix.

Removes fields marked as omitted from the parsed options.

Functions

generate_module(parsed_opts)

@spec generate_module(map()) :: Macro.t()

Generates a LiveView module for the specified UI component type.

Parameters

  • parsed_opts (map()) - Generation options with layout_tree.tag and component configuration.

Returns

Macro.t() - The generated LiveView module code.

Examples

Aurora.Uix.Templates.Basic.ModulesGenerator.generate_module(
  %{layout_tree: %{tag: :index}, name: :product,
      modules: %{caller: MyAppWeb, context: MyApp.Accounts, module: MyApp.User, web: MyAppWeb}
    }
  }
)

If the tag is not implemented, returns a quoted block with no generation logic.

handler_module(arg1, default_module)

@spec handler_module(map(), module()) :: module()

Returns the handler module or the default one.

module_name(parsed_opts, suffix)

@spec module_name(map(), binary()) :: module()

Generates a module name by concatenating the caller, module name, and suffix.

Parameters

  • modules (map()) - Module configuration with caller reference.
  • parsed_opts (map()) - Options containing module_name.
  • suffix (binary()) - String to append to module name.

Returns

  • module() - The generated module name.

Examples

Aurora.Uix.Templates.Basic.ModulesGenerator.module_name(
  %{caller: MyAppWeb}, %{module_name: "User"}, ".Index"
)
# => MyAppWeb.User.Index

remove_omitted_fields(parsed_options)

@spec remove_omitted_fields(map()) :: map()

Removes fields marked as omitted from the parsed options.

Parameters

  • parsed_options (map()) - Options with fields to filter.

Returns

  • map() - Options with omitted fields removed.

Examples

Aurora.Uix.Templates.Basic.ModulesGenerator.remove_omitted_fields(%{
  fields: [
    %{name: :foo, omitted: true},
    %{name: :bar, omitted: false}
  ]
})
# => %{fields: [%{name: :bar, omitted: false}]}