Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass blocks to widgets #11

Closed
leafo opened this issue Nov 15, 2014 · 5 comments
Closed

pass blocks to widgets #11

leafo opened this issue Nov 15, 2014 · 5 comments

Comments

@leafo
Copy link
Contributor

leafo commented Nov 15, 2014

Erector lets you do something like this:

widget Views::Thing, hello: "world" do
  div "hello world"
end

# or

widget Views::Thing.new(hello: "world") {
  div "hello world"
}

# thing.rb

class Views::Thing < Erector::Widget
  needs :hello
  def content
    div class: "hi" do
      call_block
    end
  end
end

http://www.rubydoc.info/github/erector/erector/Erector/AbstractWidget#call_block-instance_method

Would be nice if fortitude supported it

@ageweke
Copy link
Owner

ageweke commented Nov 17, 2014

Done! In master; I'll cut a new version soon. I also merged in ageweke/lazy_needs, so you shouldn't have to switch branches at all.

@ageweke ageweke closed this as completed Nov 17, 2014
@leafo
Copy link
Contributor Author

leafo commented Nov 17, 2014

Thanks

@leafo
Copy link
Contributor Author

leafo commented Nov 17, 2014

btw, If you're trying for erector compatibility then erector lets you call call_block when no block has been passed to widget and it's a no-op instead of an error

@ageweke
Copy link
Owner

ageweke commented Nov 18, 2014

Yeah — I’m trying to make Fortitude’s block handling work more like what people are used to in Ruby, where trying to yield if no block is passed actually gives an error. If this causes a lot of pain for you there at Scribd, let me know, and I’m sure we can find an alternative…

@leafo
Copy link
Contributor Author

leafo commented Nov 18, 2014

Nah, no big deal. I just override what I need to to make it work how I expect 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants