Closed pmichaeljones closed 6 months ago
Does Haml 6 work with the regular Rails capture now?
If so, we could just check if it responds_to the Haml methods instead. I'd rather not maintain another generator and template if we can avoid it.
I believe so. I've been testing out all my templates with capture
instead of capture_haml
and they appear to be working as expected.
<tbody>
<% date_range.each_slice(7) do |week| %>
<tr>
<% week.each do |day| %>
<%= content_tag :td, class: calendar.td_classes_for(day) do %>
<% capture(day, sorted_events.fetch(day, []), &passed_block) %>
<% end %>
<% end %>
</tr>
<% end %>
</tbody>
All my templates are HAML, so I pulled out the block_is_haml? and responds_to?(Haml) pieces of code.
I'm still on Haml 5 and it's working. Haml6 pulls out those methods (capture_haml, block_is_haml?, etc)
The Haml5 to Haml6 upgrade notes specifically mention using Rail's capture
method instead of capture_haml
We removed the Haml specific code back in this commit actually: https://github.com/excid3/simple_calendar/commit/9c9c8405df4232c42a372b409bc518766756a186
I think this removed the need for the haml_capture
.
Ah okay. I was unaware of the instance_exec
method. I'll give it a try tomorrow. Thanks for a great gem Chris. You're a real GEM of the rails community. horrible pun!
Hi Chris, With Haml 6, the old "hack" for the calendar isn't working anymore. HAML 6 removed a lot of methods, one of which is block_is_haml? and capture_haml.
This HAML code works for calendar layouts. You just need to make sure you're using HAML blocks, but if someone has HAML installed, they're most likely using it for all templates.
If I were to add a HAML generator to the gem, is that something you would be interested in?