Module: React::Component::Tags
- Defined in:
- lib/react/component/tags.rb
Overview
contains the name of all HTML tags, and the mechanism to register a component class as a new tag
Constant Summary collapse
- HTML_TAGS =
%w(a abbr address area article aside audio b base bdi bdo big blockquote body br button canvas caption cite code col colgroup data datalist dd del details dfn dialog div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 head header hr html i iframe img input ins kbd keygen label legend li link main map mark menu menuitem meta meter nav noscript object ol optgroup option output p param picture pre progress q rp rt ruby s samp script section select small source span strong style sub summary sup table tbody td textarea tfoot th thead time title tr track u ul var video wbr)
Class Method Summary collapse
Instance Method Summary collapse
-
#method_missing(name, *params, &children) ⇒ Object
use method_missing to look up component names in the form of “Foo(..)” where there is no preceeding scope.
-
#present(component, *params, &children) ⇒ Object
the present method is retained as a legacy behavior.
- #present_as_node(component, *params, &children) ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *params, &children) ⇒ Object
use method_missing to look up component names in the form of “Foo(..)” where there is no preceeding scope.
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/react/component/tags.rb', line 44 def method_missing(name, *params, &children) if name =~ /_as_node$/ # handle deprecated _as_node style component = find_component(name.gsub(/_as_node$/, '')) return React::RenderingContext.build_only(component, *params, &children) if component else component = find_component(name) return React::RenderingContext.render(component, *params, &children) if component end Object.method_missing(name, *params, &children) end |
Class Method Details
.included(component) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/react/component/tags.rb', line 60 def included(component) _name, parent = find_name_and_parent(component) class << parent define_method _name do |*params, &children| React::RenderingContext.render(component, *params, &children) end # handle deprecated _as_node style define_method "#{_name}_as_node" do |*params, &children| React::RenderingContext.build_only(component, *params, &children) end end end |
Instance Method Details
#present(component, *params, &children) ⇒ Object
the present method is retained as a legacy behavior
19 20 21 |
# File 'lib/react/component/tags.rb', line 19 def present(component, *params, &children) React::RenderingContext.render(component, *params, &children) end |
#present_as_node(component, *params, &children) ⇒ Object
23 24 25 |
# File 'lib/react/component/tags.rb', line 23 def present_as_node(component, *params, &children) React::RenderingContext.build_only(component, *params, &children) end |