k0kubun / hamlit

High Performance Haml Implementation
https://rubygems.org/gems/hamlit
Other
981 stars 59 forks source link

Undefined method `haml_tag' in application_helper #73

Closed ritec closed 3 years ago

ritec commented 8 years ago

Hello, first and foremost, thanks for creating this project, really looking forward to replacing the haml gem with hamlit! Now to my issue, I have the following helper method in ApplicationHelper

def grouped_accordion_item(parent, question, &answer)
  unique_id = (1..9).to_a.shuffle[0,8].join
  haml_tag :div, class: 'accordion-group' do
    haml_tag :div, class: 'accordion-heading' do
      haml_tag :a, class: 'accordion-toggle', href: "##{unique_id}", data: {toggle: 'collapse', parent: parent} do
        question
      end
    end
    haml_tag :div, class: 'accordion-body collapse', id: unique_id do
      haml_tag :div, class: 'accordion-inner' do
        yield
      end
    end
  end
end

However when the method is called from a view I get the following error: NoMethodError - undefined method haml_tag

So I go ahead and add include Hamlit::HamlHelpers in my application_helper.rb file. But then I get a different error: NoMethodError - undefined method html? for nil:NilClass: hamlit (2.5.0) lib/hamlit/parser/haml_helpers.rb:505:in haml_tag

It looks like haml_buffer is nil at this point would you know why this is? Thanks.

k0kubun commented 8 years ago

Hi. Thank you for trying Hamlit.

As I commented in https://github.com/k0kubun/hamlit/issues/71#issuecomment-224018926, some helpers are absent since Hamlit's compiled code doesn't use Haml::Buffer. It should be implemented in a different way and we don't have the one for now.

By the way, why do you prefer haml_tag rather than content_tag?

ritec commented 8 years ago

Oh, ok, I see now. Well thanks, I will try to work around these constraints. You can close this issue if you want. 👍

k0kubun commented 3 years ago

Please let me close this until somebody really needs haml_tag rather than content_tag. Thanks.

lazylester commented 1 year ago

just my $.02: It might have offered a smoother migration to first support haml_tag but with a deprecation warning, before removing it completely.

k0kubun commented 1 year ago

It never really existed in this gem. Hamlit::HamlHelpers was copied as part of the parser implementation. It's not supposed to be used outside Hamiit's engine. Hamlit does not have anything like Haml::Buffer, which powered the helpers missing in Hamlit. If it did, it would have been just as slow as original Haml, so that defeats the purpose.

k0kubun commented 1 year ago

If you're not talking about this repository but haml, yes, I think it's a fair point (but please report to the actual repository to avoid confusion next time). I think we can cut a Haml v5 release that only prints warnings in removed helpers. Would that help your current situation?

lazylester commented 1 year ago

Thank you, @k0kubun. At this point I've just about worked through incompatibilities between hamlit and haml (actually just the disappearance of haml_tag, so my previous comment was just a suggestion for how revs to widely-used code can be organized to smooth out migration for users. No need to do anything on my account. Thanks for offering, though, and most importantly, thanks for v6/hamlit. Your work is appreciated.