camillavk
camillavk

Reputation: 521

HAML - showing "|"

Very quick question concerning HAML. I'm trying to get a pipe "|" to show on my page but HAML seems to be ignoring it...

In .erb I would have written something like this:

<h3>Account |
      <%= link_to "Log in", new_user_session_path, class: "nav" %></h3>
    <% end %>

In order to show:

Account | Log in

But in HAML it's just ignoring it and showing:

Account Log in

This is the HAML code I'm trying:

%h3
   Account |
   = link_to "Log in", new_user_session_path, class: "nav"

Does anyone know what I'm doing wrong?

Upvotes: 1

Views: 155

Answers (3)

Enrai
Enrai

Reputation: 593

The "|" (pipe) character in HAML is used to merge lines in your code into one single line. You can try to escape the pipe character by using &#124;.

In the end your code should look like this:

%h3
  Account &#124;
  = link_to "Log in", new_user_session_path, class: "nav"

Upvotes: 1

Sonalkumar sute
Sonalkumar sute

Reputation: 2575

Try this

%h3
    Account
    |
    = link_to "Log in", new_user_session_path, class: "nav"

Upvotes: 0

PJ Bergeron
PJ Bergeron

Reputation: 2998

You should be able to do like this:

%h3
  Account
  |
  = link_to "Log in", new_user_session_path, class: "nav"

Or replace space by its HTML code:

%h3
  Account&#x20;|
   = link_to "Log in", new_user_session_path, class: "nav"

Upvotes: 0

Related Questions