nice_partials icon indicating copy to clipboard operation
nice_partials copied to clipboard

HAML support?

Open fauno opened this issue 1 year ago • 2 comments

Hi! I'm not able to render nice_partial with haml, I get a NicePartials::Partial::Section::RequiredError for this:

= render 'partial' do |partial|
  - partial.body do
    = 'hello'
= partial.body.required

From this I understand only ERB is supported? https://github.com/bullet-train-co/nice_partials/pull/45/files#r930773836

fauno avatar May 08 '24 15:05 fauno

Hey! Yeah, I'd like to support HAML as well. If you bundle open nice_partials and replace the regex you linked to with /\byield[\(? ]+(%>|\n|[^:])/ will it then work? Basically injecting \n as the terminator in there.

You should also be able to get NicePartials working for now with a manual yield:

= yield
= partial.body.required

You'd then need that in every partial (which is not ideal, hence why we have the automatic version).

kaspth avatar May 20 '24 23:05 kaspth

I'll try and let you know! One thing I noticed is that even if I don't use other nice_partials features, I still benefit from the implicit yield :D

fauno avatar May 21 '24 13:05 fauno