1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
17 ### Here, definition of the specific templates
19 # The root template for composers
23 # Short list of composers
24 var composers
= new Array[TmplComposer]
26 # Detailled list of composers
27 var composer_details
= new Array[TmplComposerDetail]
29 # Add a composer in both lists
30 fun add_composer
(firstname
, lastname
: String, birth
, death
: Int)
32 composers
.add
(new TmplComposer(lastname
))
33 composer_details
.add
(new TmplComposerDetail(firstname
, lastname
, birth
, death
))
36 redef fun rendering
do
47 add_all composer_details
51 # A composer in the short list of composers
58 init(name
: String) do self.name
= name
60 redef fun rendering
do add
"- {name}\n"
63 # A composer in the detailled list of composers
64 class TmplComposerDetail
72 init(firstname
, lastname
: String, birth
, death
: Int) do
73 self.firstname
= firstname
74 self.lastname
= lastname
79 redef fun rendering
do add
"""
81 COMPOSER: {{{firstname}}} {{{lastname}}}
88 ### Here a simple usage of the templates
90 var f
= new TmplComposers
91 f
.add_composer
("Johann Sebastian", "Bach", 1685, 1750)
92 f
.add_composer
("George Frideric", "Handel", 1685, 1759)
93 f
.add_composer
("Wolfgang Amadeus", "Mozart", 1756, 1791)