【发布时间】:2020-05-25 07:31:50
【问题描述】:
我的 web/templates 文件夹中有两个模板文件夹:
> ls web/templates
personal_info user
我想要的是在personal_info 的另一个视图中呈现user 文件夹中的一些模板。所以我在路径上有一个文件:web/templates/personal_info/index.html.eex,我有以下内容:
<%= render "user/xyz.html" %>
但我收到以下错误:
[error] #PID<0.821.0> running MyApp.Endpoint terminated
Server: localhost:4000 (http)
Request: GET /
** (exit) an exception was raised:
** (Phoenix.Template.UndefinedError) Could not render "user/xyz.html" for MyApp.PersonalInfoView, please define a matching clause for render/1 or define a template at "web/templates/personal_info". The following templates were compiled:
* index.html
请告诉我如何渲染在其他文件夹中定义的模板,我尝试了几种排列,但都没有奏效。
【问题讨论】:
-
参见指南中的hexdocs.pm/phoenix/views.html#sharing-views-and-templates。上面的链接和一些答案已经过时了。
标签: templates web-deployment elixir phoenix-framework