Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Third Party Component Libraries (ViewComponent) #156

Closed
mc962 opened this issue Mar 27, 2020 · 4 comments
Closed

Support for Third Party Component Libraries (ViewComponent) #156

mc962 opened this issue Mar 27, 2020 · 4 comments

Comments

@mc962
Copy link

mc962 commented Mar 27, 2020

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 rails/rails#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.

@k0kubun
Copy link
Owner

k0kubun commented Mar 28, 2020

Looking at TestComponent in rails/rails#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.

@k0kubun k0kubun closed this as completed Mar 28, 2020
@mc962
Copy link
Author

mc962 commented Sep 14, 2020

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.

@joevandyk
Copy link

joevandyk commented May 25, 2022

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)

@k0kubun
Copy link
Owner

k0kubun commented May 26, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants