user2164689
user2164689

Reputation: 377

HTML tags into ERB form

Just to add to previous question, what if you wanted to add HTML into an ERB tag

I tried to do this:

<%=button_to "<i class="fa fa-usd"></i>#{@current_user.profile.current_balance}0".html_safe, withdraw_url, :id=>"wallet_link", :class=>"btn btn-default", :method => :get %>

But that obviously gave an error. How would you add HTML tags into that?

Upvotes: 0

Views: 192

Answers (3)

Mischa
Mischa

Reputation: 43298

You can use button_to ... do, like this:

<%= button_to withdraw_url, :id => "wallet_link", :class => "btn btn-default", :method => :get do %>
  <i class="fa fa-usd"></i><%= @current_user.profile.current_balance %>0
<% end %>

Upvotes: 1

Ivan Denysov
Ivan Denysov

Reputation: 1502

<%=button_to "<i class='fa fa-usd'></i>#{@current_user.profile.current_balance}0".html_safe, withdraw_url, :id=>"wallet_link", :class=>"btn btn-default", :method => :get %>

You can't simply put double quotes inside double-quoted string. You should escape them with backslash or use single quotes

Upvotes: 1

kddeisz
kddeisz

Reputation: 5182

Couldn't you:

<%= button_to "<i class='fa fa-usd'></i>#{@current_user.profile.current_balance}0".html_safe, withdraw_url, :id=>"wallet_link", :class=>"btn btn-default", :method => :get %>

Upvotes: 0

Related Questions