Changes between Version 1 and Version 2 of Development/Code/TemplateToolkit
- Timestamp:
- Apr 17, 2012, 8:58:08 PM (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Development/Code/TemplateToolkit
v1 v2 3 3 In some cases, most of the code deals with printing correctly to a file, and it could be simplified a lot by using a basic template instead of zillions of print statements. 4 4 5 For instance, the accounts component could do .5 For instance, the accounts component could do the following to fully generate /etc/passwd: 6 6 7 7 {{{ … … 18 18 my $tpl = Template->new(); 19 19 $tpl->process(\*DATA, $tree, $fh); 20 $fh->close(); 20 21 21 22 __DATA__ … … 26 27 }}} 27 28 28 The advantage in some sitiations is that the representation is completely isolated from the logic that will generate it. And it may allow for a closer correspondency with the schema, if wanted. 29 The code would thus only choose what accounts are valid or invalid in the system. 30 31 The advantage in '''some''' sitiations is that the representation is completely isolated from the logic that will generate it. And it may allow for a closer correspondency with the schema, if wanted. 29 32 30 33 Sometimes one template won't be enough: there will be several files of several types to print (f.i, nagios-related configuration). We still have to see how to ship different templates.