Closed mc962 closed 4 years ago
Looking at TestComponent
in https://github.com/rails/rails/pull/36388, that seems totally feasible.
In that example, I think it should work by just changing ActionView::Template::Handlers::ERB.erb_implementation.new(template, trim: true).src
to Hamlit::RailsTemplate.call(template)
.
Let me close this as I'm still not sure what should be done in hamlit.gem side, but please reopen this if you have ideas of things to be done here.
I'm not sure what may have been updated in the 6 or so months since this issue was opened, but I just tried to make ViewComponent with a project that uses hamlit, and it seemed to render/behave fine.
It was a limited, initial test, so there might be unknown issues that I have not yet come across, but it seems like ViewComponent is cooperating fine with hamlit these days, with just following the instructions to install from ViewComponent's page.
I'm trying to use haml_tag
inside a viewcomponent template and getting undefined method 'haml_tag'
errors
(didn't get the error with haml)
It's intentional that Hamlit doesn't offer most of Haml's helpers like haml_tag
. REFERENCE.md says it's under development, but it's actually a wont-fix at this point. If you're using Rails, you should be able to use content_tag
. Even if it doesn't work or even exist, you should be able to define such a helper or look for such a gem yourself. Helpers in a rendering context are something template engines shouldn't care about, e.g. Slim and ERB don't, because it requires monkey-patching to achieve it with Ruby code compiled from a template. It should be the responsibility of other libraries at a proper layer.
(didn't get the error with haml)
Note that Haml is going to remove haml_tag
too. If you use the main
branch of haml/haml, you cannot use haml_tag
.
Will there be any issues with Hamlit supporting Third Party Component libraries such as github's view_component library?
I have been looking at hamlit for a project, while also following recent Rails developments concerning integrating third-party component libraries such as described in the https://github.com/rails/rails/pull/36388 PR.
From reading the description of both the Rails PR and view_component, it seems like they will support haml, and it seems like in general if haml is supported then hamlit will be supported. But I want to confirm if there might be issues with integrating hamlit with component libraries, when they are supported/released in Rails.