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

How to create a custom cell type? #146

Open
ferdynator opened this issue May 4, 2022 · 0 comments
Open

How to create a custom cell type? #146

ferdynator opened this issue May 4, 2022 · 0 comments

Comments

@ferdynator
Copy link

ferdynator commented May 4, 2022

I would like to use this library in combination with prawn-html, but I am unsure how to render HTML into a table cell.

My current approach is to create a custom cell class:

class HtmlCell < Prawn::Table::Cell
  def draw_content
    PrawnHtml.append_html(self, content)
  end
end

and use it as such:

class PrintView
  include Prawn::View

  def print_section_x
    table [["header"], [HtmlCell.make(self, "<p>Test</p>")]]
  end
end

but unfortunately the draw_content method is never called. The code clearly states that the Cell type can be extended:

# Please subclass me if you want new content types! I'm designed to be very
# extensible. See the different standard Cell subclasses in
# lib/prawn/table/cell/*.rb for a template.

but I can't find any examples. Is this currently possible?

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

No branches or pull requests

1 participant