# Make LiveView template variables readable

> Applying elixir's pipe operator makes everything better and more readable. See what a difference in readability it makes when using pipes.

- URL: https://graffino.com/til/the-cleaner-way-to-assign-liveview-template-variables
- Author: Nick Ciolpan
- Channel: elixir
- Published: 2020-09-02
- Updated: 2026-04-10

If you ever seen this in the wild: 

```
{:ok, assign(socket,
      %{my_variable: @my_variable
        my_other_variable: nil.
        yet_another_variable: nil 
      })}
```

Remember that applying elixir's pipe operator makes everything better: 

```
def mount(_session, socket) do
    socket =
      socket
      |> assign(:my_variable, @my_variable)
      |> assign(:my_other_variable, nil)
      |> assign(:yet_another_variable, nil)
    {:ok, socket}
end
```
