Skip to content

How to create a custom cell type? #146

@ferdynator

Description

@ferdynator

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions