2017-09-05 132 views
0

在我的控制器上,我返回json的index.json.jbuilderRails json返回jbuilder html標記

在控制器部分,我有一個數組,其中存儲額外的;

.. 
@ti << ('&bull; ' + e.name + ': ' + price) 
.. 

然後在我有jbuilder的部分;

.. 
json.obligatory_body @ti.join("<br>") 
.. 

我想顯示這些元素與一個子彈與內部引導彈窗內換行符。

彈出窗口裏面是這樣的;

<a tabindex="0" class="pull-right color-red " role="button" data-toggle="popover" data-container="body" data-trigger="focus" data-placement="left" title="" data-content="• Fuel: 95 €<br>• Service: 100 € " data-original-title="">Details <i class="fa fa-info-circle" aria-hidden="true"></i></a> 

這裏data-content正確顯示,但是屏幕上我看到<br>標籤以及代替換行符。

回答

1

默認情況下,Rails會轉義html標籤。請嘗試以下操作:

json.obligatory_body @ti.join("<br>").html_safe