Whiley Mai
Whiley Mai

Reputation: 149

How to add a span class in ruby to HTML markup

I am not familiar with ruby, but need to add a span class of money to a li item. I have tried

Orginal

<li class="list-group-item cart-text-drawer shipping-results border-0"><%= rates[i].name %> at <%= rates[i].price %></li>

My failed attempt

<li class="list-group-item cart-text-drawer shipping-results border-0"><%= rates[i].name %> at <%= :span, class: 'money' rates[i].price %></li>

Could the proper method be explained. Thanks

Upvotes: 0

Views: 80

Answers (1)

Andr&#233; Luiz
Andr&#233; Luiz

Reputation: 40

Since span is a HTML tag you don't need to put it inside ruby code. Simply add the tag as you would do using plain HTML and add the ruby inside of it, as seen below:

<li class="list-group-item cart-text-drawer shipping-results border-0">
  <%= rates[i].name %> at 
  <span class="money">
    <%= rates[i].price %>
  </span>
</li>

Upvotes: 1

Related Questions