x_component v0.1.0 X.Transformer View Source

Contains a set of functions to transform compiled Elixir AST into more performance optimized AST. Also, it contains functions to transform Elixir AST for inline components.

Link to this section Summary

Functions

Transform given Elixir AST into a valid X template AST.

Transform given X template Elixir AST into optimized inline component AST.

Link to this section Functions

Link to this function

compact_ast(tree)

View Source
compact_ast(Macro.t()) :: Macro.t()
Link to this function

transform_expresion(ast, context, env)

View Source
transform_expresion(Macro.t(), atom(), Macro.Env.t()) :: Macro.t()

Transform given Elixir AST into a valid X template AST.

  • transforms globals @var into assigns Map.get/2 function call.
  • transforms @assigns and @yield into local variables.
  • add given context module to the local variables context.
  • transforms imported function call into function call from the imported module.
  • expands all aliases.
Link to this function

transform_inline_component(module, assigns, children, line)

View Source
transform_inline_component(atom(), Keyword.t(), Macro.t(), integer()) ::
  Macro.t()

Transform given X template Elixir AST into optimized inline component AST.

  • replaces dynamic :attrs with string build in compile time when it's possible.
  • replaces local variables with given assigns.
  • replaces yield local variables with given children AST.