jensljungblad / elemental_components

Simple view components for Rails 5.1+
MIT License
76 stars 5 forks source link

Introduce named variable for captured block #42

Closed msalzburg closed 4 years ago

msalzburg commented 4 years ago

This PR implements the "Introduce named variable for captured block" strategy from Issue #32.

It defines a #block and a #block? method to access the captured, nested block content.

jensljungblad commented 4 years ago

@msalzburg Looking at https://github.com/github/actionview-component, it seems like they went with this strategy as well, but named the variable content. Should we do the same perhaps?

jensljungblad commented 4 years ago

We could also add a test case for validating its presence.

msalzburg commented 4 years ago

Hi @jensljungblad - I updated this branch by merging your small refactoring and renamed the block handling methods to .content and .content? (again). Since the content block is optional I am not sure which presence you would like to validate?

Maybe we can squeeze this feature in your upcoming 1.0.0 release?

jensljungblad commented 4 years ago

I'll give you a chance to reply to my comment above but I'm happy to merge as is :)

jensljungblad commented 4 years ago

Eh, decided to just merge it :) Maybe I'll have a go at adding the tests.

jensljungblad commented 4 years ago

Thanks a lot for the contribution!

jensljungblad commented 4 years ago

@msalzburg Released as 1.0.0.rc2.

msalzburg commented 4 years ago

Awesome - thanks!