Created
April 12, 2018 02:11
-
-
Save chadwilken/a3f370a59a44ca1912dc691c44912708 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module ReactHelper | |
def react_component(name, props: {}, html_class: nil) | |
content_tag( | |
'div', | |
nil, | |
class: html_class, | |
data: { controller: 'react', 'react-component' => name, 'react-props' => react_props(props) } | |
) | |
end | |
def react_props(**args) | |
return nil if args.nil? | |
JSON.dump(args) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment