Created
June 14, 2024 08:35
-
-
Save chanakasan/234957a9abe5aeff3b7b3f0e50391dd0 to your computer and use it in GitHub Desktop.
view component helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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