chandradot99
chandradot99

Reputation: 3876

Convert erb ruby code to slim template

Below is an erb ruby code which is want to convert in slim template

    <div class="star-rating" data-score= <%= review.rating%> ></div>

In above template i am confused as there are two equals to sign

online converter is giving something like this

.star-rating data-score="<haml_loud"  review.rating &gt;

But its not working

Upvotes: 1

Views: 218

Answers (2)

bogl
bogl

Reputation: 1864

<%= ... > in Erb means to evaluate the expression inside, and include the result in the outer context. Thus if the rating would be 99, then data-score=99 would become part of the html. That is fine.

The generated output seems wrong. The trailing &gt; should be inside a string, just as the opening counterpart "<haml_loud. And as jeffdill2 correctly pointed out, there is no need to use haml_loud. Just use:

.star-rating data-score=review.rating

Upvotes: 1

jeffdill2
jeffdill2

Reputation: 4114

This will work for you:

.star-rating data-score=review.rating

Since you're (apparently) using Slim, not Haml, you don't need haml_loud at all.

Upvotes: 1

Related Questions