你會如何轉換此.html.haml文件.html.erb?在瀏覽器中轉換html.haml - > html.erb
.rating-total{data: {id: @post.id, score: @avg_score || 0 }}
.total-score= @avg_score ? @avg_score.round(1) : 0
輸出應該是這樣的(如2帖子ID):
<div class='rating-total' data-id='2' data-score='0'></div>
<div class='total-score'>0.0</div>
我這個試過,但我沒有得到在正確的輸出瀏覽器:在瀏覽器中
<div class="rating-total" data-id="#{@post.id}" data-score= "#{@avg_score || 0}"></div>
<div class="total-score">
<%= @avg_score ? @avg_score.round(1) : 0 %>
</div>
輸出:
<div class="rating-total" data-id="#{@post.id}" data-score= "#{@avg_score || 0}"></div>
<div class="total-score">2.3</div>
你目前在瀏覽器中的輸出是什麼? – FabKremer
我嘗試了不同的代碼,但沒有輸出正確的post.id和avg_score ...我更新了帖子 – Absurdim