template :: TmplComposerDetail
A composer in the detailled list of composerscore :: union_find
union–find algorithm using an efficient disjoint-set data structure
module tmpl_composer is example
import template
### Here, definition of the specific templates
# The root template for composers
class TmplComposers
super Template
# Short list of composers
var composers = new Array[TmplComposer]
# Detailled list of composers
var composer_details = new Array[TmplComposerDetail]
# Add a composer in both lists
fun add_composer(firstname, lastname: String, birth, death: Int)
do
composers.add(new TmplComposer(lastname))
composer_details.add(new TmplComposerDetail(firstname, lastname, birth, death))
end
redef fun rendering do
add """
COMPOSERS
=========
"""
add_all composers
add """
DETAILS
=======
"""
add_all composer_details
end
end
# A composer in the short list of composers
class TmplComposer
super Template
# Short name
var name: String
redef fun rendering do add "- {name}\n"
end
# A composer in the detailled list of composers
class TmplComposerDetail
super Template
var firstname: String
var lastname: String
var birth: Int
var death: Int
redef fun rendering do add """
COMPOSER: {{{firstname}}} {{{lastname}}}
BIRTH...: {{{birth}}}
DEATH...: {{{death}}}
"""
end
### Here a simple usage of the templates
var f = new TmplComposers
f.add_composer("Johann Sebastian", "Bach", 1685, 1750)
f.add_composer("George Frideric", "Handel", 1685, 1759)
f.add_composer("Wolfgang Amadeus", "Mozart", 1756, 1791)
f.write_to(stdout)
lib/template/examples/tmpl_composer.nit:15,1--87,18