Module: Invoicing::LedgerItem::RenderHTML
- Defined in:
- lib/invoicing/ledger_item/render_html.rb
Overview
Included into ActiveRecord model object when acts_as_ledger_item
is invoked.
Defined Under Namespace
Classes: HTMLOutputBuilder
Instance Method Summary collapse
-
#render_html(options = {}) {|output_builder| ... } ⇒ Object
Shortcut for rendering an invoice or a credit note into a human-readable HTML format.
Instance Method Details
#render_html(options = {}) {|output_builder| ... } ⇒ Object
Shortcut for rendering an invoice or a credit note into a human-readable HTML format. Can be called without any arguments, in which case a general-purpose representation is produced. Can also be given options and a block for customising the output:
@invoice = Invoice.find(params[:id])
@invoice.render_html :quantity_column => false do |i|
i.date_format "%d %B %Y" # overwrites default "%Y-%m-%d"
i.recipient_label "Customer" # overwrites default "Recipient"
i.sender_label "Supplier" # overwrites default "Sender"
i.description_tag do |params|
"<p>Thank you for your order. Here is our invoice for your records.</p>\n" +
"<p>Description: #{params[:description]}</p>\n"
end
end
23 24 25 26 27 |
# File 'lib/invoicing/ledger_item/render_html.rb', line 23 def render_html(={}, &block) output_builder = HTMLOutputBuilder.new(self, ) yield output_builder if block_given? output_builder.build end |