Module: Cedar::Component
- Includes:
- Arbre::HTML
- Defined in:
- lib/cedar/component.rb
Overview
InlineRender provides a ‘render` dsl to your components which will render any arbre tree within.
It will also convert snake case component names to component instances for example, this would be equivalent to ‘ButtonComponent.new(label: “Test”)`
“‘ruby render do
div do
label: "Test"
end
end “‘
Instance Method Summary collapse
- #find_component(name) ⇒ Object
-
#render(&blk) ⇒ Object
The empty first arg is just to trick rubymine when using ‘render` inside the arbre context.
Instance Method Details
#find_component(name) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/cedar/component.rb', line 31 def find_component(name) if const_defined?(name) const_get(name) else if superclass.respond_to?(:find_component) superclass.find_component(name) else adjusted_name = name.chomp("Component").underscore raise(NameError, "undefined local variable or method `#{adjusted_name}` for #{self}") end end end |