sandrods / odf-report

Generates ODF files, given a template (.odt) and data, replacing tags

Home Page:http://sandrods.github.com/odf-report

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Placeholders inside table are not replaced

jaredbeck opened this issue · comments

Following the table example at http://sandrods.github.io/odf-report/, I was able to get multiple table rows in the output, but they only contain placeholders.

To reproduce:

# frozen_string_literal: true

require "odf-report"

Fruit = Struct.new(:id, :description)
data = [
  Fruit.new(1, 'banana'),
  Fruit.new(2, 'kiwi')
]

template_path = File.expand_path("my.template.odt", __dir__)
report = ODFReport::Report.new(template_path) do |r|
  r.add_field :address, "My new address"
  r.add_table("mytable", data, :header=>false) do |t|
    t.add_column(:item_id, :id)
    t.add_column(:description) { |item| "==> #{item.description}" }
  end
end

output_path = File.expand_path("my.out.odt", __dir__)
report.generate(output_path)

Template

| [ITEM_ID] | [DESCRIPTION] |

[ADDRESS]

Expected output

| 1 | Banana |
| 2 | Fruit |

My new address

Actual output

| [ITEM_ID] | [DESCRIPTION] |
| [ITEM_ID] | [DESCRIPTION] |

My new address

Analysis

It's partly working. The [ADDRESS] is getting replaced, and we're seeing a row added to the table.

I think the documentation must be missing something simple?

Take a look at #69

Take a look at #69

Thanks. Replacing the entire contents of the cell seems to work.

Should we add this to the docs?

I would gladly accept a PR for the docs