函数 Discuss.TopicView.render/2 未定义(模块 Discuss.TopicView 不可用)
function Discuss.TopicView.render/2 is undefined (module Discuss.TopicView is not available)
创建一个 Phoenix 框架应用程序,开发人员可以在其中添加主题进行讨论,一切都很顺利 运行,直到我在 templates/view/index.html.eex
中添加此代码:
<h5>Topics</h5>
<ul class="collection">
<%= for topic <- @topics do %>
<li class="collection-item">
<%= topic.title %>
</li>
<% end %>
</ul>
<div class="fixed-action-btn">
<%= link to: topic_path(@conn, :new), class: "btn-floating btn-large waves-effect waves-light red" %>
<i class="material-icons">add</i>
<% end %>
</div>
问题似乎出在上面的语法上,但我该如何在圆形红色按钮内应用加号图标?
在我的终端中我得到:
== Compilation error in file web/views/topic_view.ex ==
** (EEx.SyntaxError) web/templates/topic/index.html.eex:14: unexpected end of expression <% end %>
我正在与:Phoenix v1.2.5
如果你不小心的话,这里有一个大陷阱。
绝对是语法错误。在 Phoenix 中创建 link 标签时,请确保在结束 Phoenix 标签之前添加 do
关键字。
所以代替:
<div class="fixed-action-btn">
<%= link to: topic_path(@conn, :new), class: "btn-floating btn-large waves-effect waves-light red" %>
<i class="material-icons">add</i>
<% end %>
</div>
这样写:
<div class="fixed-action-btn">
<%= link to: topic_path(@conn, :new), class: "btn-floating btn-large waves-effect waves-light red" do %>
<i class="material-icons">add</i>
<% end %>
</div>
我看到这个 post 才发现它不见了:
https://elixirforum.com/t/how-to-add-i-tag-in-to-link-function/12040
创建一个 Phoenix 框架应用程序,开发人员可以在其中添加主题进行讨论,一切都很顺利 运行,直到我在 templates/view/index.html.eex
中添加此代码:
<h5>Topics</h5>
<ul class="collection">
<%= for topic <- @topics do %>
<li class="collection-item">
<%= topic.title %>
</li>
<% end %>
</ul>
<div class="fixed-action-btn">
<%= link to: topic_path(@conn, :new), class: "btn-floating btn-large waves-effect waves-light red" %>
<i class="material-icons">add</i>
<% end %>
</div>
问题似乎出在上面的语法上,但我该如何在圆形红色按钮内应用加号图标?
在我的终端中我得到:
== Compilation error in file web/views/topic_view.ex == ** (EEx.SyntaxError) web/templates/topic/index.html.eex:14: unexpected end of expression <% end %>
我正在与:Phoenix v1.2.5
如果你不小心的话,这里有一个大陷阱。
绝对是语法错误。在 Phoenix 中创建 link 标签时,请确保在结束 Phoenix 标签之前添加 do
关键字。
所以代替:
<div class="fixed-action-btn">
<%= link to: topic_path(@conn, :new), class: "btn-floating btn-large waves-effect waves-light red" %>
<i class="material-icons">add</i>
<% end %>
</div>
这样写:
<div class="fixed-action-btn">
<%= link to: topic_path(@conn, :new), class: "btn-floating btn-large waves-effect waves-light red" do %>
<i class="material-icons">add</i>
<% end %>
</div>
我看到这个 post 才发现它不见了: https://elixirforum.com/t/how-to-add-i-tag-in-to-link-function/12040