Created
April 3, 2009 17:22
-
-
Save linojon/89844 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def menu_item( name, url_options={}, section_url=nil, &block) | |
#debugger | |
current = current_page?(url_options) | |
content = content_tag :li, :class => (current ? 'current' : nil) do | |
link_to(name, url_options) + | |
(block.nil? ? '' : capture(&block)) | |
end | |
block.nil? ? concat(content, binding) : concat(content, block.binding) | |
end | |
# what to put for binding in concat(content, binding) ? | |
#==================== | |
# case: simple block | |
<% menu_item 'Project', overview_project_path(current_project) do %> | |
Hello | |
<% end %> | |
=> works! | |
<li><a href="/projects/poetry_contest/overview">Project</a> | |
Hello | |
</li> | |
#==================== | |
# case: no block | |
<% menu_item 'Project settings', edit_project_path(current_project) %> | |
=> ERROR | |
undefined local variable or method `_erbout' for #<ActionView::Base:0xaaad2c8> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment