Skip to content

Instantly share code, notes, and snippets.

@chanakasan
Created June 14, 2024 08:35
Show Gist options
  • Save chanakasan/234957a9abe5aeff3b7b3f0e50391dd0 to your computer and use it in GitHub Desktop.
Save chanakasan/234957a9abe5aeff3b7b3f0e50391dd0 to your computer and use it in GitHub Desktop.
view component helper
# frozen_string_literal: true
module ComponentHelper
def component(name, *, **, &)
component_name = "#{name}_component".split('__').map(&:classify).join('::')
render(component_name.constantize.new(*, **), &)
end
def component_alt(name, *, **, &)
component_name = "#{name}__component".split('__').map(&:classify).join('::')
render(component_name.constantize.new(*, **), &)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment