Permalink
Browse files

added a @note that I'm unsure about the name of the block() methid

  • Loading branch information...
1 parent ad88930 commit 51348986d55a9a051bccb1d0dd83d30006a1a728 @justinfrench justinfrench committed Apr 27, 2011
Showing with 2 additions and 0 deletions.
  1. +2 −0 app/helpers/nestive/layout_helper.rb
@@ -111,6 +111,8 @@ def extends(name, &block)
#
# @param [Symbol] name
# A unique name to identify this block of content.
+ #
+ # @todo Method name bugs me... "block" is a confusing term given Ruby also has blocks. It's also not a verb like append, extend, etc. How about declare? assign? define?
def block(name, content=nil, &block)
content = capture(&block) if block_given?
append(name, content)

6 comments on commit 5134898

tjogin commented on 5134898 Apr 28, 2011

Agreed, block already has special meaning in Ruby. But, what else? Maybe "placeholder" or "content"?

On a related note, the name of the "replace" method seems a bit off to me. Maybe "set"?

Love the simplicity and focus of the library though, and how, as far as I can see, it should be compatible with any kind of template language the user may prefer, right?

Contributor

justinfrench replied Apr 28, 2011

Thanks!

How about box or container instead of block? It's not a verb, but probably doesn't need to be.

replace works when you think about overriding content previously set by a parent, but doesn't make as much sense when you're setting the content for the first time I guess. We could alias set to replace, but that kind of bugs me too. Will think about it.

Should be compat with anything that can deal with the ERB blocks, but yeah, it' pretty vanilla code.

I think box or container are both perfectly alright, they're both at least not names of Ruby constructs. :)

I had that same reservation of replace; it works when you're replacing, but it's weird when you're initially setting. And I figure the latter would be the more common case, plus set still works when you're replacing. It's just nitpicking of course.

Contributor

justinfrench replied Apr 28, 2011

Breakfast brainstorm on block/box/container (box was the winner) with @quamen, we're now back to a verb: insert.

Contributor

justinfrench replied Apr 28, 2011

And with a bit more talking and a bit more coffee — I like a noun to replace block (eg box) because the documentation becomes easy (you're appending content to the box, rather than appending content to the unnamed thing you inserted into the layout earlier :)

Sounds good, the docs just needs to be clear that insert replaces whatever contents previously in the box. I don't think that's going to be a problem.

Please sign in to comment.