Skip to content

Instantly share code, notes, and snippets.

@paulcsmith
Created April 26, 2020 17:32
Show Gist options
  • Save paulcsmith/c0e2d0fc6b5bc95dd39b372ae5d41152 to your computer and use it in GitHub Desktop.
Save paulcsmith/c0e2d0fc6b5bc95dd39b372ae5d41152 to your computer and use it in GitHub Desktop.
Mount with block
def mount(component, *args, **named)
component.new(*args, **named).render do |*yield_args|
yield *yield_args
end
end
class Component
def initialize(@name : String)
end
def render
yield @name
end
end
mount Component, name: "paul" do |name|
puts name
end
mount(Component, name: "paul", &.upcase)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment