0
votes

Creating a Phoenix framework application where developers can add topics for discussion and everything was running smoothly until I added this code inside of 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>

The problem does seem to be the syntax above, but how do I go about applying the plus icon inside of the round red button?

In my terminal I am getting:

== Compilation error in file web/views/topic_view.ex == ** (EEx.SyntaxError) web/templates/topic/index.html.eex:14: unexpected end of expression <% end %>

I am working with: Phoenix v1.2.5

1

1 Answers

0
votes

A big gotcha here if you are not careful.

It was definitely a syntax error. When creating link tags in Phoenix ensure you add the dokeyword at the end before closing Phoenix tag.

So instead of:

<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>

write it like this:

<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>

I only noticed it missing after seeing this post: https://elixirforum.com/t/how-to-add-i-tag-in-to-link-function/12040