hyper-react icon indicating copy to clipboard operation
hyper-react copied to clipboard

children method should respond to `to_proc` and `render`

Open catmando opened this issue 7 years ago • 0 comments

For example

# add the class funky to any DIV
class FunkyDiv < Hyperloop::Component
  collect_all_other_params_as :opts
  render do
    opts = params.opts.dup
    opts[:class] = "funky #{opts[:class]}"
    DIV(opts, &children)  # &children ==> children.to_proc
    # rather than 
    # { children.each &:render }
  end
end

class TableWithHeader < Hyperloop::Component
  render do
    TABLE do 
      TH { ... }
      children.render
     end
   end
end

catmando avatar Jul 17 '18 20:07 catmando