Hi everyone,
So I am trying to render in app.html.eex a partial that I have in /shared/_menu.html.eex
folder in templates and i created a view for it in /views/menu_view.ex
menu_view.ex content
defmodule BlogApiWeb.MenuView do
use BlogApiWeb, :view
end
app.html.eex part that renders this template
<body>
<%= render BlogApiWeb.MenuView, "_menu.html", assigns %>
<section role="main" class="container">
<p class="alert alert-info" role="alert"><%= get_flash(@conn, :info) %></p>
<p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>
<%= render @view_module, @view_template, assigns %>
</section>
<script type="text/javascript" src="<%= Routes.static_path(@conn, "/js/app.js") %>"></script>
</body>
The error
Request: GET /
** (exit) an exception was raised:
** (Phoenix.Template.UndefinedError) Could not render "_menu.html" for BlogApiWeb.MenuView, please define a matching clause for render/2 or define a template at "lib/blog_api_web/templates/menu". No templates were compiled for this module.
So i am wondering why do I get this error and why it is pattern matching with this
defp render_template(template, assigns) do
template_not_found(template, Map.put(assigns, :__phx_template_not_found__, __MODULE__))
end
from here https://github.com/phoenixframework/phoenix/blob/master/lib/phoenix/template.ex
Also full code on github here https://github.com/wolfiton/blog_api
Thanks in advance