require "amrita/template" include Amrita tmpl = TemplateText.new <

This group has no data.
This group has only one data: "".
Here's the list of this group's data.
END data = [ ["Group A", %w(only_one)], ["Group B", %w(one two three)], ["Group C", %w()] ] model_data = data.collect do |name, d| hash = {:title => name } case d.size when 0 hash[:no_data] = true when 1 hash[:one_data] = { :data=>d[0] } else hash[:many_data] = { :list=>d } end hash end tmpl.prettyprint = true tmpl.expand(STDOUT, { :groups=>model_data })