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

Doesn't work within a Helper #2

Open
cschiefelbein opened this issue Nov 17, 2009 · 0 comments
Open

Doesn't work within a Helper #2

cschiefelbein opened this issue Nov 17, 2009 · 0 comments

Comments

@cschiefelbein
Copy link

This looks great but it relies on the <%= ... %> construction for th and td elements to be displayed.

If you move the example code into a helper, e.g.

def example
    @front_men = [FrontMan.new(1, 'David St. Hubbins'), FrontMan.new(2, 'David Lee Roth')]

    table_for(@front_men) do |t|
      t.head do
        t.r do
          t.h('Id')
          t.h('Name')
        end
      end
      t.body do |front_man|
        t.r do
          t.d(h(front_man.id))
          t.d(h(front_man.name))
        end
      end
    end
end

The output will include the table and tr tags, but it won't have any content. Passing the content in as a block has the same effect.

Also, for some reason, when the helper method example() is invoked from the .html.erb file, the contents of both are duplicated (my h1 followed by my table, followed by my h1 followed by my table). I believe this is caused by table_helper, because when I replace the table_for() call in example() with a regular old content_tag(), the duplication does not occur.

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

1 participant