jensljungblad / elemental_components

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

Remove value in favor of content #18

Closed jensljungblad closed 6 years ago

jensljungblad commented 6 years ago

This PR fixes #17 and changes the elements API. Instead of having a value that can be set either with a block or as a parameter when initializing an element (and component), there is now only a content variable that can only be set with a block. This simplifies the code a bit because it doesn't have to deal with shifting parameter order.

It also removes the to_s method on element. You now have to explicitly print the content variable. This makes things more consistent between components and elements.

It also hopefully clarifies the API a bit. It would have been nice to name the variable yield instead of content but that is a reserved word in Ruby.