Closed alphamarket closed 6 years ago
The breadcrumb name isn't changed by anything in the codebase, it is a simple value. Rails marks all strings as unsafe. I would apply raw
, not when you specify breadcrumb but when you render it in a view.
<%= link_to raw(crumb.name), crumb.url, .... %>
However, I would really question using html in Rails controller, it feels wrong, it would be better to use a placeholder value, e.i. breadcrumb :home_icon, :root_path
and then in your view:
<% if crumb.name == :home_icon %>
<span class="fa fa-home"></span>
<% end %>
This way you will avoid HTML in your controller and having unsafe strings, there is a reason why it is not working out of the box in Rails.
for some reasons I need to have only this, I have alread put the raw
when I render the item, the result is still the same!
<%= link_to crumb.url, (crumb.current? ? {'aria-current' => 'page'} : {}) do %>
<%= raw crumb.name %>
<% end %>
This way you will avoid HTML in your controller and having unsafe strings, there is a reason why it is not working out of the box in Rails.
I am no so stricked guy; I allow myself to have some liberty in using html in my controller (life is easy this way) but I've never had this issue before.
Having looked at your example again I have realised that by default each breadcrumb is truncated to 30 chars, this was based on the assumption that there will only be ever a name without HTML markup etc..
However, I think this arbitrary limit does more harm than good and this gem shouldn't need to worry about such things since my preference would be for people to control how they display things in their views and keep names as simple data.
Therefore, I went ahead and removed the truncation and capitalization of titles from the library, which as a side effect will allow you to put virtually anything as a title! - for the no so strict guy 😜
Please install v0.8.0
and let me know if you problem gets resolved.
Yes, the problem got fixed, Thanks!
let's say I have the following:
The output is:
I have tried
raw|html_safe
on the name, but result is the same!