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

Using a Mustache View to render additional data... #228

Open
nzifnab opened this issue Nov 16, 2016 · 0 comments
Open

Using a Mustache View to render additional data... #228

nzifnab opened this issue Nov 16, 2016 · 0 comments

Comments

@nzifnab
Copy link

nzifnab commented Nov 16, 2016

So my mustache view looks something like this:

class StatementDocumentData < Mustache
  def initialize(statement)
    @statement = statement
  end

  def invoices
    @statement.invoices.map do |invoice|
      data = InvoiceDocumentData.new(invoice)
      data[:additional_information] = "Something extra"
      data
    end
  end
end

Where InvoiceDocumentData follows a similar structure (some methods to define data available to a mustache template). The idea here is that the same view data can be used from within the statements' invoice loop, or from within an individual statement template itself (We use different mustache views depending on the situation)... However, I'm noticing that no matter how I structure it, the dict-style addition :additional_information doesn't seem to be available to the template, and it just renders empty.

All of the method-defined values in InvoiceDocumentData are working correctly.

Any idea why the dict-style definition isn't working here? Or what I can do to work around it? I tried setting values on data.context and/or returning the context instead of the View itself but nothing seems to do quite what I had in mind.

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