# Render Expects Template to be a String

**URL:** <https://forum.elixirforum.com/t/render-expects-template-to-be-a-string/33147>\
**Category:** Questions\
**Tags:** phoenix, phoenix\_html, render, plug-conn\
**Created:** [July 16, 2020, 11:53am UTC](https://forum.elixirforum.com/t/render-expects-template-to-be-a-string/33147 "2020-07-16T11:53:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hizqeel](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hizqeel/32/19852_2.png) [@Hizqeel](https://forum.elixirforum.com/u/Hizqeel)\
**Post date:** [July 16, 2020, 11:53am UTC](https://forum.elixirforum.com/t/render-expects-template-to-be-a-string/33147/1 "2020-07-16T11:53:12Z")

</div>

Hi, I am writing an authentication plug, upon failure I am rendering to `403` error page

```elixir
    case claims do
      {:ok, claims} ->
        conn
        |> put_status(200)

      _ ->
        conn
        |> render("forbidden.html")
        |> halt()
    end

```

It gives me this error

```elixir
** (ArgumentError) render/2 expects template to be a string, got: %Plug.Conn{adapter: {Plug.Cowboy.Conn, :...}, assigns: %{}

```

I don’t know what I am doing wrong here, Any help would be highly appreciated!

---

<div class="post-metadata">

**Author:** ![hauleth](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hauleth/32/18942_2.png) [@hauleth](https://forum.elixirforum.com/u/hauleth)\
**Post date:** [July 16, 2020, 11:56am UTC](https://forum.elixirforum.com/t/render-expects-template-to-be-a-string/33147/2 "2020-07-16T11:56:43Z")

</div>

Are you sure you are using correct `render/2` function? Especially as in this case you should use `put_view/2` or `render/3`.

---

<div class="post-metadata">

**Author:** ![Hizqeel](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hizqeel/32/19852_2.png) [@Hizqeel](https://forum.elixirforum.com/u/Hizqeel)\
**Post date:** [July 16, 2020, 12:12pm UTC](https://forum.elixirforum.com/t/render-expects-template-to-be-a-string/33147/3 "2020-07-16T12:12:42Z")

</div>

I don’t know I am thinking it right or not as It is a simple html page I am using `render/2`, In `render/3` I need to pass `assign`

---

<div class="post-metadata">

**Author:** ![Hizqeel](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hizqeel/32/19852_2.png) [@Hizqeel](https://forum.elixirforum.com/u/Hizqeel)\
**Post date:** [July 17, 2020, 8:39am UTC](https://forum.elixirforum.com/t/render-expects-template-to-be-a-string/33147/5 "2020-07-17T08:39:01Z")

</div>

As I was rendering the user to error page so what I did is create a render function in View and render template there:

```elixir
  def render("403.html", _assigns) do
    render("forbidden.html", %{})
  end

```

and in my authentication pipe:

```elixir
case claims do
  {:ok, claims} ->
    conn
    |> put_status(200)

   _ ->
    conn
    |> put_status(403)
    |> put_view(MyAppWeb.PageView)
    |> render("403.html")
    |> halt()
end

```
