+1
0001-Fix-Avoid-literal-string-will-be-frozen-in-the-futur.patch
- clss << " nwday" if @gantt.non_working_week_days.include?(wday)
+ clss += " nwday" if @gantt.non_working_week_days.include?(wday)
How about modifying it like this?
clss = "gantt_hdr"
clss << " nwday" if @gantt.non_working_week_days.include?(wday)
%>
- <%= content_tag(:div, :style => style, :class => clss) do %>
+ <%= content_tag(:div, :style => style, :class => ["gantt_hdr", { nwday: @gantt.non_working_week_days.include?(wday) }]) do %>
<%= day_num.day %>
<% end %>
<%
With this change, the class attribute would produce the following results:
redmine-app(dev)> helper.content_tag(:div, "", :class => ["gantt_hdr", { nwday: false }])
=> "<div class=\"gantt_hdr\"></div>"
redmine-app(dev)> helper.content_tag(:div, "", :class => ["gantt_hdr", { nwday: true }])
=> "<div class=\"gantt_hdr nwday\"></div>"
Alternatively, this approach would also work:
- clss = "gantt_hdr"
+ clss = +"gantt_hdr"
clss << " nwday" if @gantt.non_working_week_days.include?(wday)
Reasons:
- The current implementation in the patch always creates a new string instance.
- Other similar parts of the code use String#+@, so this would improve consistency.
Personally, I think the former approach is preferable, but the latter also seems like a valid option.