Viewplex.Component (viewplex v0.2.0) View Source

This module provides the base implementation of all components. When useing the module, you can pass a list of fields as you would for Kernel.defstruct/1... The struct fields will be used to filter/ cast the assigns passed to the directly to the template. Bear in mind that this module inner implementation relies heavily on Phoenix.View.

Examples

No assigns allowed:

  defmodule MyComponent do
    use Viewplex.Component
  end

Allowing only the :name property:

  defmodule MyComponent do
    use Viewplex.Component, [:name]
  end

Allowing the :name property and defining a default value:

  defmodule MyComponent do
    use Viewplex.Component, [name: "John"]
  end