Closed joelhawksley closed 5 years ago
@cgriego this PR doesn't affect the testability, it simply changes the source of the template string.
That hadn't been addressed really
Can you be more specific? We're able to unit test components now, and are able to at least audit what methods on the component have been called.
I'd love to see a sample implementation using content_tag
and the associated benchmarks!
@cgriego I am using components with the content_tag
for quite some time. There is nothing difficult about that – those can be simple PORO classes.
I think the appeal of @joelhawksley approach is the possibility to use simplified (shorter, more HTML-like) markup – be it .html.erb
or .slim
or whatever – and take benefit of standard Rails-y things such as fragment caching.
The missing piece in my opinion are CSS/JS assets located in the same folder as the component, and perhaps even some mechanism for their namespacing.
One of the stated hopes for components was to address the testability and code coverage measurability of these reusable view objects. That hadn't been addressed really, but this feels like a step away from it. Using helpers like
content_tag
inside the Ruby class could work, but what about exposing Builder or something like it to construct HTML inside the class? And there could also be arender
method available inside the class to render template files to a developer's heart's content.