# `PromEx.DashboardRenderer`
[🔗](https://github.com/akoutmos/prom_ex/blob/master/lib/prom_ex/dashboard_renderer.ex#L1)

This module is used to read dashboard definitions, render EEx dashboards,
and ensure that requested files actually exist

# `t`

```elixir
@type t() :: %PromEx.DashboardRenderer{
  assigns: keyword() | nil,
  decoded_dashboard: map() | nil,
  error: tuple() | nil,
  file_contents: String.t(),
  file_type: :eex | :json | nil,
  full_path: term(),
  otp_app: term(),
  relative_path: String.t(),
  rendered_file: String.t() | nil,
  valid_file?: boolean(),
  valid_json?: boolean() | nil
}
```

# `apply_dashboard_function`

```elixir
@spec apply_dashboard_function(t(), (map() -&gt; map())) :: t()
```

This function will execute a provided function on the rendered dashboard to give the user a chance to
adjust the dashboard definition.

# `build`

```elixir
@spec build(
  dashboard_otp_app :: atom(),
  dashboard_relative_path :: String.t(),
  metrics_otp_app :: atom()
) :: t()
```

Read the contents of a dashboard file entry. If an EEx version of the file exists,
read that, else fallback to the provided file name. For example, if the requested
dashboard file is `ecto.json`, if `ecto.json.eex` exists, then that will be returned.
This is more so for convenience so that you don't need to write out `.eex` everywhere
given that all PromEx 1st party dashboards are EEx templates.

# `decode_dashboard`

```elixir
@spec decode_dashboard(t()) :: t()
```

This function will decode the JSON dashboard using `Jason`. If any errors occur during the decoding process,
the struct will be marked as having invalid JSON.

# `merge_assigns`

```elixir
@spec merge_assigns(
  t(),
  keyword()
) :: t()
```

This function will merge in the provided assigns to the struct's assigns. These assigns will
then be used during the `render_dashboard/1` call to render any EEx template statements.

# `render_dashboard`

```elixir
@spec render_dashboard(t(), prom_ex_module :: module()) :: t()
```

Renders the dashboard. If it is an EEx file then the PromEx module assigns are passed. Else
if it is a raw json file then it is passed through untouched.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
