none
authorMikeMannix <MikeMannix>
Sat, 8 Sep 2001 14:55:16 +0000 (14:55 +0000)
committerMikeMannix <MikeMannix>
Sat, 8 Sep 2001 14:55:16 +0000 (14:55 +0000)
TWiki/TWikiMetaData.mdwn
TWiki/TWikiTemplates.mdwn

index d1790f3..e695080 100644 (file)
@@ -233,25 +233,20 @@ Should only be present if there is a FORM entry. Note that this data is used whe
 
 ### <a name="Recommended Sequence"></a> Recommended Sequence
 
-There no absolute need for meta data variables to be in a specific order, however, it does for the following reasons:
+There is no absolute need for Meta Data variables to be listed in a specific order within a topic, but it makes sense to do so a couple of good reasons:
 
-- Keep (form) fields in the order they are defined
-- Allow diff command to give output in a logically sensible order
+- form fields remain in the order they are defined
+- the `diff` function output appears in a logical order
 
-These could be done in other ways, but this adds complexity
-
-- Order fields - definition could be read on each rendering (expensive)
-- Diff - render data before doing diff, has something to offer, but not likely to be available for next TWiki release
-
-So the order is:
+The recommended sequence is:
 
 - TOPICINFO
-- text of topic
-- TOPICMOVED - optional
-- TOPICPARENT - optional
-- FILEATTACHMENT - 0 or more entries
-- FORM - optional
-- FIELD - 0 or more entries (FORM required)
+- `text of topic`
+- TOPICMOVED (optional)
+- TOPICPARENT (optional)
+- FILEATTACHMENT (0 or more entries)
+- FORM (optional)
+- FIELD (0 or more entries; FORM required)
 
 ## <a name="Viewing Meta Data in Page Source"></a> Viewing Meta Data in Page Source
 
@@ -261,9 +256,9 @@ When viewing a topic the <code>**Raw Text**</code> link can be clicked to show t
 
 ## <a name="Rendering Meta Data"></a> Rendering Meta Data
 
-Meta Data is rendered with the %META% variable. This is mostly used in the <code>**view**</code>, <code>**preview**</code> and <code>**edit**</code> scripts.
+Meta Data is rendered with the %META% variable. This is mostly used in the `view`, `preview` and `edit` scripts.
 
-Current support is fairly basic:
+Current support covers:
 
 <table border="1" cellpadding="0" cellspacing="0">
   <tr>
@@ -279,7 +274,7 @@ Current support is fairly basic:
     <td> Show attachments, exclude hidden </td>
   </tr>
   <tr>
-    <td> Options for attachments: </td>
+    <td> Options for [[Main/FileAttachments]]: </td>
     <td>   </td>
   </tr>
   <tr>
@@ -322,6 +317,6 @@ Current support is fairly basic:
 
 ## <a name="Known Issues"></a> Known Issues
 
-There is currently no support for meta data for Plugins. However, the format is readily extendable and the `Meta.pm` code that supports the format needs only minor alteration.
+At present, there is no Meta Data support for Plugins. However, the format is readily extendable and the `Meta.pm` code that supports the format needs only minor alteration.
 
 -- [[JohnTalintyre]] - 29 Aug 2001 <br />
index 2b28eb3..641faec 100644 (file)
@@ -1,27 +1,16 @@
-# <a name="new topic for the final doc"></a> new topic for the final doc
-
-Slightly edited down, but waiting for new docs, hopefully.
-
-see also for ref: orig [[TWikiTemplatingSystem]]
-
 <div>
   <ul>
-    <li><a href="#new topic for the final doc"> new topic for the final doc</a></li>
-    <li><a href="#TWiki Template System"> TWiki Template System</a></li>
-    <li><a href="#Overview"> Overview</a><ul>
-        <li><a href="#Needs of the TWiki templating sy"> Needs of the TWiki templating system</a></li>
-        <li><a href="#Functional Spec"> Functional Spec</a></li>
-        <li><a href="#Examples"> Examples</a><ul>
-            <li>
-              <ul>
-                <li><a href="#Base template oopsbase.tmpl"> Base template oopsbase.tmpl</a></li>
-                <li><a href="#Test template oopstest.tmpl"> Test template oopstest.tmpl</a></li>
-                <li><a href="#Sample screen shot of oopstest.t"> Sample screen shot of oopstest.tmpl</a></li>
-              </ul>
-            </li>
+    <li><a href="#TWiki Template System"> TWiki Template System</a><ul>
+        <li><a href="#Overview"> Overview</a></li>
+        <li><a href="#Major changes from the previous"> Major changes from the previous template system</a></li>
+        <li><a href="#Functional Specifications"> Functional Specifications</a></li>
+        <li><a href="#New Template System by Example"> New Template System by Example</a><ul>
+            <li><a href="#Base template oopsbase.tmpl"> Base template oopsbase.tmpl</a></li>
+            <li><a href="#Test template oopstest.tmpl"> Test template oopstest.tmpl</a></li>
+            <li><a href="#Sample screen shot of oopstest.t"> Sample screen shot of oopstest.tmpl</a></li>
           </ul>
         </li>
-        <li><a href="#Comments and feedback"> Comments and feedback</a></li>
+        <li><a href="#Known Issues"> Known Issues</a></li>
       </ul>
     </li>
   </ul>
@@ -29,207 +18,181 @@ see also for ref: orig [[TWikiTemplatingSystem]]
 
 # <a name="TWiki Template System"></a> TWiki Template System
 
-_Define the templates used to render all HTML pages displayed in TWiki_
+_Definition of the templates used to render all HTML pages displayed in TWiki_
 
-# <a name="Overview"></a> Overview
+## <a name="Overview"></a> Overview
 
-We have a need for more advanced template handling. As [[JohnTalintyre]] pointed out in [[CommonHeaderFooterTemplate]] it makes sense to separate the header and footer into one file so that it can be easily altered (or even overloaded by a skin). Also the oops dialog messages are all identical except for a few variables like heading, and so on.
+The new modular template system is more flexible, efficient, and easily updated than the old set-up, where each template is a complete HTML file. The new master template approach places common templates parts, like headers and footers, in one shared file. This simplifies the conversion of templates into XHTML format, and provides a more versatile solution for templates and for [[skins|Main/TWikiDocumentation#TWiki_Skins]].
 
-Using external modules like the [[TemplateToolkit]] would be one way to go, but this will add a lot of baggage to TWiki.
+## <a name="Major changes from the previous"></a><a name="Major changes from the previous "></a> Major changes from the previous template system
 
-## <a name="Needs of the TWiki templating sy"></a> Needs of the TWiki templating system
+The main difference is that templates are now defined using variables to include template parts. You change one stored instance of a common element to update all occurrences. The new system:
 
-- Separate common parts into one (or more) base template file(s) and include that from other template files like `view.tmpl`.
-- Define common variables like a "|" separator in the base template and use them in other template files
-- Define variable text in templates (i.e. `view.tmpl`) and pass them to the base template
+- separates a set of common template parts into a base template that is included by all of the related templates;
 
-## <a name="Functional Spec"></a> Functional Spec
+- defines common variables, like a standard separator (ex: "|"), in the base template;
 
-I tried to define a simple but powerful solution that can be extended over time. Here we go:
+- defines variable text in the individual templates and passes it back to the base template.
+
+## <a name="Functional Specifications"></a> Functional Specifications
 
 - Special template directives (or preprocessor commands) are embedded in normal templates.
 - Use of template directives is optional, templates work without them.
-- All template preprocessing is done in `&TWiki::Store::readTemplate()` so that the caller simply gets an expanded template file (the same as before)
-- Directives are of form `%TMPL:<key>%` and `%TMPL:<key>{"attr"}%`.
+- All template preprocessing is done in `&TWiki::Store::readTemplate()` so that the caller simply gets an expanded template file (the same as before).
+- Directives are of the form `%TMPL:<key>%` and `%TMPL:<key>{"attr"}%`.
 - Initial set of directives:
   - `%TMPL:INCLUDE{"file"}%`: Includes a template file. The usual search path is applied.
   - `%TMPL:DEF{"var"}%`: Define a variable. Text between this and the END directive is not returned, but put into a hash for later use.
   - `%TMPL:END%`: Ends variable definition.
   - `%TMPL:P{"var"}%`: Prints a previously defined variable.
-- New directives can be added over time when needed, i.e. IF-THEN-ELSE.
-- Variables live in a global name space, there is no parameter passing.
-- Two pass processing, so that you can use a variable before declaring it or after.
-- Templates and skins work transparently and interchangeably. You could for example define a new skin just for the header &amp; footer and keep the other template files unchanged.
-- **_Note:_** The template directive work only for templates, they do not get processed in topic text.
+- New directives can be added over time when needed, ex: IF-THEN-ELSE.
+- Variables are live in a global name space, there is no parameter passing.
+- Two-pass processing, so that you can use a variable before declaring it or after.
+- Templates and [[skins|Main/TWikiDocumentation#TWiki_Skins]] work transparently and interchangeably. For example, you can create a skin that overloads just the `twiki.tmpl`, like `twiki.print.tmpl`, that redefines the header and footer.
+- **_Note:_** The template directives work only for templates, they do not get processed in topic text.
 
-## <a name="Examples"></a> Examples
+## <a name="New Template System by Example"></a> New Template System by Example
 
-Attached is an example of an oops base template `oopsbase.tmpl` and a example oops dialog `oopstest.tmpl` which is based on the base template. This is not the version that will go into the release, it is just a quick hack.
+Attached is an example of an oops base template `oopsbase.tmpl` and a example oops dialog `oopstest.tmpl` which is based on the base template. **_NOTE:_** This isn't the release version, just a quick, simple demo.
 
-#### <a name="Base template oopsbase.tmpl"></a> Base template oopsbase.tmpl
+### <a name="Base template oopsbase.tmpl"></a> Base template oopsbase.tmpl
 
 The first line declares the delimiter variable called "sep", used to separate multiple link items. The variable can be called anywhere by writing `%TMPL:P{"sep"}%`
 
-**_Note:_** Added a dot to escape rendering of variables, i.e. read <code>**%.WEB%**</code> as <code>**%WEB%**</code>.
-
-    <table border="1" cellspacing="0" cellpadding="1">
-    <tr><td>
-    <verbatim>
-    %.TMPL:DEF{"sep"}% | %.TMPL:END%
-    <html>
-    <head>
-      <title> %.WIKITOOLNAME% . %.WEB% . %.TOPIC% %.TMPL:P{"titleaction"}%</title>
-      <base href="%.SCRIPTURL%/view%.SCRIPTSUFFIX%/%.WEB%/%.TOPIC%">
-      <meta name="robots" content="noindex">
-    </head>
-    <body bgcolor="#FFFFFF">
-    <table width="100%" border="0" cellpadding="3" cellspacing="0">
-      <tr>
-        <td bgcolor="%.WEBBGCOLOR%" rowspan="2" valign="top" width="1%">
-               <a href="%.WIKIHOMEURL%">
-               <img src="%.PUBURLPATH%/wikiHome.gif" border="0"></a>
-        </td>
-        <td>
-               <b>%.WIKITOOLNAME% . %.WEB% . </b><font size="+2">
-               <B>%.TOPIC%</b> %.TMPL:P{"titleaction"}%</font>
-        </td>
-      </tr>
-      <tr bgcolor="%.WEBBGCOLOR%">
-        <td colspan="2">
-               %.TMPL:P{"webaction"}%
-        </td>
-      </tr>
-    </table>
-    --- ++ %.TMPL:P{"heading"}%
-    %.TMPL:P{"message"}%
-    <table width="100%" border="0" cellpadding="3" cellspacing="0">
-      <tr bgcolor="%.WEBBGCOLOR%">
-        <td valign="top">
-               Topic <b>%TOPIC%</b> . {
-                 %.TMPL:P{"topicaction"}%
-               }
-        </td>
-      </tr>
-    </table>
-    </body>
-    </verbatim>
-    </td></tr>
-    </table >
-
-#### <a name="Test template oopstest.tmpl"></a> Test template oopstest.tmpl
+**_NOTE:_** Added a dot to escape rendering of variables, i.e. read <code>**%.WEB%**</code> as <code>**%WEB%**</code>.
+
+> <table border="1" cellspacing="0" cellpadding="1">
+>     <tr><td>
+>     <verbatim>
+>     %.TMPL:DEF{"sep"}% | %.TMPL:END%
+>     <html>
+>     <head>
+>       <title> %.WIKITOOLNAME% . %.WEB% . %.TOPIC% %.TMPL:P{"titleaction"}%</title>
+>       <base href="%.SCRIPTURL%/view%.SCRIPTSUFFIX%/%.WEB%/%.TOPIC%">
+>       <meta name="robots" content="noindex">
+>     </head>
+>     <body bgcolor="#FFFFFF">
+>     <table width="100%" border="0" cellpadding="3" cellspacing="0">
+>       <tr>
+>       <td bgcolor="%.WEBBGCOLOR%" rowspan="2" valign="top" width="1%">
+>              <a href="%.WIKIHOMEURL%">
+>              <img src="%.PUBURLPATH%/wikiHome.gif" border="0"></a>
+>       </td>
+>       <td>
+>              <b>%.WIKITOOLNAME% . %.WEB% . </b><font size="+2">
+>              <B>%.TOPIC%</b> %.TMPL:P{"titleaction"}%</font>
+>       </td>
+>       </tr>
+>       <tr bgcolor="%.WEBBGCOLOR%">
+>       <td colspan="2">
+>              %.TMPL:P{"webaction"}%
+>       </td>
+>       </tr>
+>     </table>
+>     --- ++ %.TMPL:P{"heading"}%
+>     %.TMPL:P{"message"}%
+>     <table width="100%" border="0" cellpadding="3" cellspacing="0">
+>       <tr bgcolor="%.WEBBGCOLOR%">
+>       <td valign="top">
+>              Topic <b>%TOPIC%</b> . {
+>                %.TMPL:P{"topicaction"}%
+>              }
+>       </td>
+>       </tr>
+>     </table>
+>     </body>
+>     </verbatim>
+>     </td></tr>
+>     </table >
+
+### <a name="Test template oopstest.tmpl"></a> Test template oopstest.tmpl
 
 Each oops template basically just defines some variables and includes the base template that does the layout work.
 
-<table border="1" cellpadding="1" cellspacing="0">
+> <table border="1" cellpadding="1" cellspacing="0">
+>   <tr>
+>     <td><pre>
+> %.TMPL:DEF{"titleaction"}% (test =titleaction=) %.TMPL:END%
+> %.TMPL:DEF{"webaction"}% test =webaction= %.TMPL:END%
+> %.TMPL:DEF{"heading"}%
+> Test heading %.TMPL:END%
+> %.TMPL:DEF{"message"}%
+> Test =message=. Blah blah blah blah blah blah blah blah blah blah blah...
+>
+>    * Some more blah blah blah blah blah blah blah blah blah blah...
+>    * Param1: %PARAM1%
+>    * Param2: %PARAM2%
+>    * Param3: %PARAM3%
+>    * Param4: %PARAM4%
+> %.TMPL:END%
+> %.TMPL:DEF{"topicaction"}%
+> Test =topicaction=:
+> [[%.WEB%.%TOPIC%][OK]] %.TMPL:P{"sep"}%
+> [[%.TWIKIWEB%.TWikiRegistration][Register]] %.TMPL:END%
+> %.TMPL:INCLUDE{"oopsbase"}%
+> </pre></td>
+>   </tr>
+>   <tr>
+>     <td> &lt;/table &gt; </td>
+>   </tr>
+> </table>
+
+### <a name="Sample screen shot of oopstest.t"></a> Sample screen shot of oopstest.tmpl
+
+With URL: <code>**.../bin/oops/Test/TestTopic2?template=oopstest&amp;param1=WebHome&amp;param2=WebNotify**</code>
+
+> <table border="1" cellpadding="0" cellspacing="0">
+>   <tr>
+>     <td><img alt="testscreen.gif" height="304" src="http://www.dementia.org/twiki//view/testscreen.gif" width="554" /></td>
+>   </tr>
+> </table>
+
+All common template parts are defined in one master template, `twiki.tmpl`, that all other templates include.
+
+<table border="1" cellpadding="0" cellspacing="0">
   <tr>
-    <td><pre>
-%.TMPL:DEF{"titleaction"}% (test =titleaction=) %.TMPL:END%
-%.TMPL:DEF{"webaction"}% test =webaction= %.TMPL:END%
-%.TMPL:DEF{"heading"}%
-Test heading %.TMPL:END%
-%.TMPL:DEF{"message"}%
-Test =message=. Blah blah blah blah blah blah blah blah blah blah blah...
-
-   * Some more blah blah blah blah blah blah blah blah blah blah...
-   * Param1: %PARAM1%
-   * Param2: %PARAM2%
-   * Param3: %PARAM3%
-   * Param4: %PARAM4%
-%.TMPL:END%
-%.TMPL:DEF{"topicaction"}%
-Test =topicaction=:
-[[%.WEB%.%TOPIC%][OK]] %.TMPL:P{"sep"}%
-[[%.TWIKIWEB%.TWikiRegistration][Register]] %.TMPL:END%
-%.TMPL:INCLUDE{"oopsbase"}%
-</pre></td>
+    <th bgcolor="#99CCCC"><strong> Template variable: </strong></th>
+    <th bgcolor="#99CCCC"><strong> Defines: </strong></th>
   </tr>
   <tr>
-    <td> &lt;/table &gt; <p>
-      </p>
-      <h4><a name="Sample screen shot of oopstest.t"></a> Sample screen shot of oopstest.tmpl </h4>
-      <p> With URL: <code><b>.../bin/oops/Test/TestTopic2?template=oopstest&amp;param1=WebHome&amp;param2=WebNotify</b></code></p>
-      <p>
-      </p>
-      <table border="1" cellpadding="0" cellspacing="0">
-        <tr>
-          <td><img alt="testscreen.gif" height="304" src="http://www.dementia.org/twiki//view/testscreen.gif" width="554" /></td>
-        </tr>
-      </table>
-      <p>
-      </p>
-      <h2><a name="Comments and feedback"></a> Comments and feedback </h2>
-      <p>
-      </p>
-      <ul>
-        <li> The itching factor to put this into the upcoming release is to easy the pending converstion of the templates into XHTML format and to have a more flexible solution for templates and skins. </li>
-        <li> Is the terminology OK? </li>
-        <li> Is the spec OK? </li>
-        <li> Are there any other directives that are needed urgently? </li>
-        <li> One drawback by using the directives is that you can only test a template from within TWiki. This is because you don't have a text that has a linear flow when you use TMPL:DEF, TMPL:P and TMPL:INCLUDE. </li>
-      </ul>
-      <p> -- [[Main/PeterThoeny]] - 21 Jul 2001 <br />
-      </p>
-      <p>
-      </p>
-      <ul>
-        <li> It's probably more readable to enforce variables being defined before use, which would avoid need for slower two-pass processing. <ul>
-            <li> [ [[Main/PeterThoeny]] ] You need two-pass processing because you need to define the "|" separator in the included template onone side, and on the other side define variables for the included template. The processing happens as regex in memory, so there is no mesurable speed penalty. </li>
-          </ul>
-        </li>
-        <li> It would be nice to simplify the syntax a bit, e.g. not using "" around variable names (they don't really need it, unlike filenames), and not using braces - however, this is not a big deal and there is some merit in keeping consistent with the current TWiki syntax. <ul>
-            <li> [ [[Main/PeterThoeny]] ] The templating system uses the standard internal TWiki function to parse variable attributes. The "" can be skipped (is possible but is not documented). </li>
-          </ul>
-        </li>
-      </ul>
-      <p>
-      </p>
-      <p> Please have a look at the latest templates in the [[Main/TWikiAlphaRelease]]. There is now one master template called <code>twiki.tmpl</code> that all other templates include (well, will include when all done). The idea is to define all common parts of the templates in <code>twiki.tmpl</code> and simply use that from all other templates. </p>
-      <p>
-      </p>
-      <table border="1" cellpadding="0" cellspacing="0">
-        <tr>
-          <th bgcolor="#99CCCC"><strong> Template variable: </strong></th>
-          <th bgcolor="#99CCCC"><strong> Defines: </strong></th>
-        </tr>
-        <tr>
-          <td> %TMPL:DEF{"sep"}% </td>
-          <td> %TMPL:END% </td>
-          <td> "|" separator </td>
-        </tr>
-        <tr>
-          <td> %TMPL:DEF{"htmldoctype"}% </td>
-          <td> Start of all HTML pages </td>
-        </tr>
-        <tr>
-          <td> %TMPL:DEF{"standardheader"}% </td>
-          <td> Standard header (for view, rdiff, ... </td>
-        </tr>
-        <tr>
-          <td> %TMPL:DEF{"simpleheader"}% </td>
-          <td> Simple header with reduced links (for edit, attach, oops,...) </td>
-        </tr>
-        <tr>
-          <td> %TMPL:DEF{"standardfooter"}% </td>
-          <td> Footer, excluding revision part and copyright part </td>
-        </tr>
-        <tr>
-          <td> %TMPL:DEF{"oops"}% </td>
-          <td> Skeleton of oops dialog </td>
-        </tr>
-      </table>
-      <p> I.e. the <code>preview.tmpl</code> template is now simply: </p><pre>
-%TMPL:INCLUDE{"twiki"}%
-%TMPL:DEF{"titleaction"}% (oops) %TMPL:END%
-%TMPL:DEF{"webaction"}% *Attention* %TMPL:END%
-%TMPL:DEF{"heading"}% Topic is not saved yet %TMPL:END%
-%TMPL:DEF{"message"}%
-  Please go back in your browser and save the topic. %TMPL:END%
-%TMPL:DEF{"topicaction"}% %TMPL:END%
-%TMPL:P{"oops"}%
-</pre><p> With this it should be possible to create a skin that overloads just the <code>twiki.tmpl</code>, i.e. a <code>twiki.print.tmpl</code> that redefines the header and footer. </p>
-      <p> -- [[Main/PeterThoeny]] - 23 Jul 2001 <br /> -- [[Main/MikeMannix]] - 30 Aug 2001 </p>
-      <p>
-      </p>
-    </td>
+    <td> %TMPL:DEF{"sep"}% </td>
+    <td> "|" separator </td>
+  </tr>
+  <tr>
+    <td> %TMPL:DEF{"htmldoctype"}% </td>
+    <td> Start of all HTML pages </td>
+  </tr>
+  <tr>
+    <td> %TMPL:DEF{"standardheader"}% </td>
+    <td> Standard header (ex: view, index, seach) </td>
+  </tr>
+  <tr>
+    <td> %TMPL:DEF{"simpleheader"}% </td>
+    <td> Simple header with reduced links (ex: edit, attach, oops) </td>
+  </tr>
+  <tr>
+    <td> %TMPL:DEF{"standardfooter"}% </td>
+    <td> Footer, excluding revision and copyright parts </td>
+  </tr>
+  <tr>
+    <td> %TMPL:DEF{"oops"}% </td>
+    <td> Skeleton of oops dialog </td>
   </tr>
 </table>
+
+> **Example: `preview.tmpl` template**
+>
+>     %TMPL:INCLUDE{"twiki"}%
+>     %TMPL:DEF{"titleaction"}% (oops) %TMPL:END%
+>     %TMPL:DEF{"webaction"}% *Attention* %TMPL:END%
+>     %TMPL:DEF{"heading"}% Topic is not saved yet %TMPL:END%
+>     %TMPL:DEF{"message"}% Please go back in your browser and save the topic. %TMPL:END%
+>     %TMPL:DEF{"topicaction"}%
+>     %TMPL:END%
+>     %TMPL:P{"oops"}%
+
+## <a name="Known Issues"></a> Known Issues
+
+- A drawback of referring to a master template is that you can only test a template from within TWiki, where the include variables are resolved. In the previous system, each template is a structurally complete HTML document with a `.tmpl` filename extension - it contains unresolved `%VARIABLES%`, but can still be previewed directly in a browser.
+
+-- [[PeterThoeny]] - 23 Jul 2001 <br /> -- [[MikeMannix]] - 30 Aug 2001