How can I pass the variable to inline style tag in rails

<div style="--rating: <%= rating_value %>">

^Work's fine

but doesn't work with .erb syntax.

<%= content_tag :div, style: "--rating: <%= rating_value %>" %>

what am I missing? Thanx for the answer!

Upvotes: 2

Views: 347

Answers (1)

Smek
Smek

Reputation: 1208

This should work:

<%= content_tag :div, style: "--rating: #{rating_value}" %>

Upvotes: 1

Related Questions