Templates in Ruport class

Hello, all.

How can I use a templates in the ruport. Does the ruport class support
templates?

Thank you.

On 2/20/07, Firstname S. [email protected] wrote:


Posted via http://www.ruby-forum.com/.

Hi Firstname,
Try the Ruport group:
http://groups.google.com/group/ruby-reports

On 2/20/07, Firstname S. [email protected] wrote:

Hello, all.

How can I use a templates in the ruport. Does the ruport class support
templates?

You mean ERb templates? Yeah, we support them, though I’ve never had
any feature requests or suggestions about them so I tend to forget
they’re even there. Here is a simple example

foo.rb

require “ruport”

class MyReport < Ruport::Report

def generate
@html_table = [[1,2,3],[4,5,6]].to_table(%w[a b c]).to_html
erb “foo.rhtml”
end

end

puts MyReport.run

foo.rhtml

<%= @html_table %>

If you’d like to chat about this some more, the best place to do it is
the Ruport mailing list
( http://list.rubyreports.org ) [ which is just a different URI for
the same list Chris C. linked ]

warm regards,
-greg

On 2/21/07, Artem L. [email protected] wrote:

No, I mean, that if I have a query and I need to display data in
different formats(html, pdf, csv), can I describe data’s view in some
file such as test.xml:

No. But let’s talk about this over on the Ruport list. Sounds like a
great idea for a plugin.

Those following along can find the thread here:

http://tinyurl.com/2rqxb6

I’ll give a detailed reply there.

Gregory B. wrote:

On 2/20/07, Firstname S. [email protected] wrote:

Hello, all.

How can I use a templates in the ruport. Does the ruport class support
templates?

You mean ERb templates? Yeah, we support them, though I’ve never had
any feature requests or suggestions about them so I tend to forget
they’re even there. Here is a simple example

No, I mean, that if I have a query and I need to display data in
different formats(html, pdf, csv), can I describe data’s view in some
file such as test.xml:

<?xml version="1.0"?> Something: Report's name ..................... .....................

or in yaml format, and after this when I generate my report in all
formats, I will have data good looking.

Now, when I execute code somthing like this:

class MyRuport < Ruport::Report
include DogTag

attr_accessor :main_query
attr_accessor :parameters
attr_accessor :output_format

prepare do

generate do

query(main_query, {:as => output_format.to_sym})

end

end

ruport = MyReport.new
ruport.main_query = “select * from test_table”
ruport.output_format = “html”

ruport.run{ |res| puts res.results }

I have results:

id test

O something like this in pdf…

Can I put into my project some template file that will give outout data
looks better? And how can I do this with ruport. And have the ruport
some standart ways to solve this problem.

Thank you for answers. Artem L…