|
NAMETemplate::Magic::QuickGuide - A quick start for WebmastersQuick Start for WebmastersOverviewIf you are a webmaster you don't need to know perl in order to completely customize the output of any perl script that uses Template::Magic: you have just to edit the templates that the perl script uses, and you will have the full power on the script output. Well... the full power the perl programmer decided to give you ;-).TemplatesTemplates are simple files used by the Template::Magic system in order to produce the output. Depending on the application, a template might be a text, html, xml, or any other type of file. Usually the template is composed by static text (i.e. the text that will never be changed by the application), and a few delimited zones (labels or blocks), that will be substituted by the application with dynamic data produced by the program. The merging of the static text and the program data will produce the output of the program.This is a very simple template file: City: {city} Date and Time: {date_and_time} where {city} and {date_and_time} are just zones (labels) that the application recognizes and replaces with some real runtime values. The remaining text is static text which will be included verbatim in the output. The following may be an output: City: NEW YORK Date and Time: Sat Nov 16 21:03:31 2002 Zones: Labels and BlocksA 'zone' is a special delimited place in the template, that the Template::Magic system recognizes as a zone. Depending on the implementation decided by the programmer, the zones of each application may be delimited by a different set of characters. Usually the default delimiters are "{ }" or "<!--{ }-->" (which are default delimiters included in HTML comments, very handy in HTML WYSIWYG editors).A zone may have a content or not. A zone with no content is also a label, while a zone with content is also a block: a label: {identifier} a block: {identifier} content of the block {/identifier} Identifiers are case sensitive and are defined by the programmer. He should provide a list of recognized labels and block, along with a description of each zone. Repeating blocksOftenly an application is required to produce lists. It can do so by implementing a repeating block. The content of the repeating block will be parsed and the included labels and blocks will be substituted with the actual data as many time as necessary in order to produce the full list output:{visit_list} City: {city} Date and Time: {date_and_time} {/visit_list} The following may be an output: City: NEW YORK Date and Time: Sat Nov 16 21:03:31 2002 City: WASHINGTON Date and Time: Sun Nov 17 18:21:40 2002 City: MIAMI Date and Time: Mon Nov 18 16:38:16 2002 the NOT_* blockFor any label or block you can use a NOT_* zone (where '*' stands for the zone id) which will automatically be printed if the zone is not printed, or wiped out if the zone is printed.{visit_list} City: {city} Date and Time: {date_and_time}{NOT_date_and_time}N/A{/NOT_date_and_time} {/visit_list} {NOT_visit_list} No visit to report {/NOT_visit_list} The following may be an output: City: DENVER Date and Time: N/A City: WASHINGTON Date and Time: Sun Nov 17 18:21:40 2002 City: MIAMI Date and Time: Mon Nov 18 16:38:16 2002 The following may be another output: No visit to report INCLUDE_TEXT and INCLUDE_TEMPLATEYou can inlude a template or a static text file by using 2 special lables: INCLUDE_TEXT and INCLUDE_TEMPLATE. The include text will include verbatim the text found into the file, while INCLUDE_TEMPLATE will parse the file first, substituting labels and blocks with actual data.{INCLUDE_TEMPLATE /templates/temp_file.html} {INCLUDE_TEXT /templates/text_file.html} Paths are relative to the current template. Customizing a templateYou can customize all the static text in any template, you can also omit or move any label or block inside any template. You can split a template into chunks and include each chunk with an INCLUDE_TEXT or an INCLUDE_TEMPLATE label, or you can join different included templates chunk into a single template.In special cases, when the programmer implemented this possibility, you can also pass some custom parameters to some custom labels in order to further customize the output. Anyway, the label and block definition along with the production of the dynamic content is always controlled by the application. SYNTAX GLOSSARY
AUTHOR and COPYRIGHT© 2004-2005 by Domizio Demichelis (<http://perl.4pro.net>)All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as perl itself. POD ERRORSHey! The above document had some coding errors, which are explained below:
Visit the GSP FreeBSD Man Page Interface. |