Closed nicolas-brousse closed 6 years ago
Hello @nicolas-brousse,
You can't do that now, but we can introduce this behavior.
You can override the component helper in your own project by defining a custom component helper in your app/helpers/pplication_helper.rb
:
def component(component_name, locals = {}, options = {}, &block)
captured_block = proc { |args| capture(args, &block) } if block_given?
Komponent::ComponentRenderer.new(
controller,
).render(
component_name,
locals,
options,
&captured_block
)
end
alias :c :component
Thanks @florentferry.
It works for me.
It could be nice to have it implemented inside Komponent 😃
I'm trying to create a component to have a form container. And so use yield to pass the form helper to the view from the component.
So I did the following.
But I got this error :
ActionView::Template::Error (undefined method
label' for nil:NilClass)`.I tried to print the content of
form
orf
. I have the form helper object inside the container, but in the viewf
is nil.Does the block inside the view is rendered before the component?