Closed spdawson closed 4 years ago
@spdawson thank you for the report! We definitely want to make sure haml
works with ViewComponent. Would you be willing to write a PR with a test case for this issue?
@joelhawksley I've added a test case in #428
Thanks @spdawson! Would you be up for pairing with me on this one? Send me an email: joelhawksley@github.com
I would be willing to help if it's needed. I plan to use view components with Haml at work. If Haml doesn't work with view components right now, it's a blocker. Let me know how I can help.
@dmarcoux send me your pairing availability for the next week to joelhawksley@github.com ❤️
@dmarcoux send me your pairing availability for the next week to joelhawksley@github.com heart
Done :slightly_smiling_face:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
hey @spdawson @dmarcoux
I was taking a look at this issue and the repository provided, I noticed it is using helpers.link_to
.
As https://github.com/github/view_component/pull/428#discussion_r468713628 explained, helpers.
is unnecessary in this situation and removing it solved the issue (at least in the provided repo)
Could you confirm that removing helpers.
fixes the issue? Also, is there any specific reason as why you are using helpers.
?
Could you confirm that removing
helpers.
fixes the issue? Also, is there any specific reason as why you are usinghelpers.
?
Yes, removing the helpers.
scope does resolve this issue for me; thanks @dmarcoux!
I do get this error even without any helpers
in my templates. My component however renders a rails form and another component within it.
default.html.erb (preview template):
<%= form_with model: @gig do |f| %>
<%= render Places::EditComponent.new(form: f, attr_name: :venue) %>
<% end %>
edit_component.html.haml (the component itself):
= @form.fields_for @attr_name do |pf|
%div{class: errors.present? ? 'has-error' : ''}
= render Places::MapComponent.new(place: place, style: @style, fireEvent: @fireEvent)
The error message points to the @form.fields_for
line.
Btw: If I write the default.html.erb
template in haml (instead of straight erb), I get the following error:
A preview template for example default does not exist.
To fix this issue, create a template for the example.
Is there anything special to set up in order to use templates for previewing view components?
Steps to reproduce
Minimal reproduction repository
Expected behavior
Component should render without incident, when using Haml template.
Actual behavior
Error is raised:
System configuration
Rails version: 6.0.3.2
Ruby version: 2.7.1
Gem version: 2.18.0