class Tilt::CSVTemplate
template.render(self)
template = Tilt::CSVTemplate.new { tpl }
]
{:name => “Simone Carletti”, :id => 3}
{:name => “Ryan Tomayko”, :id => 2},
{:name => “Joshua Peek”, :id => 1},
@people = [
EOS
end
csv << [person, person]
@people.each do |person|
# data rows
csv << [‘NAME’, ‘ID’]
# header
tpl = <<-EOS
# Example of csv template
== Example
CSV Template implementation. See:
def precompiled(locals)
def precompiled(locals) source, offset = super [source, offset + 1] end
def precompiled_template(locals)
def precompiled_template(locals) <<-RUBY #{@outvar} = CSV.generate(**#{@options}) do |csv| #{@data} end RUBY end
def prepare
def prepare @outvar = @options.delete(:outvar) || '_csvout' end