module Cedar::Component
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 button label: "Test" end
end “`
Public Instance Methods
find_component(name)
click to toggle source
# 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
render(&blk)
click to toggle source
The empty first arg is just to trick rubymine when using `render` inside the arbre context
# File lib/cedar/component.rb, line 24 def render(&blk) define_method :call do ctx = Context.new(self) ctx.instance_eval(&blk).to_s end end