- Timestamp:
- 11/25/08 00:57:30 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/TemplateToolkitPlugin/data/TWiki/TemplateToolkitPlugin.txt
r878 r929 5 5 6 6 This is a rather slim glue to Andy Wardley's Template Toolkit 7 (see http://www.template-toolkit.org/ or TWiki:Codev.TemplateToolkit 8 for more, though the latter is pretty stale). 7 (see http://www.template-toolkit.org/ for more. 9 8 10 9 I myself have here and then argued that TT is too heavyweight for use 11 as a template system for TWiki, but this does only prevent using TT as12 the _only_ template system for TWiki.10 as a template system for Foswiki, but this does only prevent using TT as 11 the _only_ template system for Foswiki. 13 12 14 13 If, on the other hand, you _do_ have TT installed anyway, and 15 14 especially if you have it running in a mod_perl environment where 16 15 module compilation time is no longer an issue, then you might want to 17 share your TT blocks or layouts with TWiki.16 share your TT blocks or layouts with Foswiki. 18 17 19 18 The implementation as a plugin does not allow to install TT 20 as a drop-in replacement for TWiki's own templating system. But I19 as a drop-in replacement for Foswiki's own templating system. But I 21 20 think that for first experiments it is possible to emulate that: Use 22 very slim TWiki templates to get TWiki's template system out of21 very slim Foswiki templates to get Foswiki's template system out of 23 22 the way, and run your topics through TT instead. 24 23 25 24 To be honest, I am using this plugin as both a first step to evaluate 26 TT as a TWiki template machine, and as a real-life hands-on example25 TT as a Foswiki template machine, and as a real-life hands-on example 27 26 for BenchmarkContrib to play with. 28 27 … … 31 30 ---++ Syntax Rules 32 31 33 The plugin has just one TWiki tag in the TWiki sense:32 The plugin has just one Foswiki tag in the Foswiki sense: 34 33 35 34 %STARTSECTION{"VarTEMPLATETOOLKIT"}% … … 38 37 processed by TT. 39 38 * A configuration variable named 40 =$ TWiki::cfg{Plugins}{TemplateToolkitPlugin}{UseTT}= can be used39 =$Foswiki::cfg{Plugins}{TemplateToolkitPlugin}{UseTT}= can be used 41 40 to set a site-wide default 42 41 * Supported Parameters: … … 52 51 53 52 All configuration variables for this plugin are collected under 54 =$ TWiki::cfg{Plugins}{TemplateToolkitPlugin}=.53 =$Foswiki::cfg{Plugins}{TemplateToolkitPlugin}=. 55 54 56 55 | *Configuration Variable* | *Description* | 57 56 | ={UseTT}= | Sitewide default for TT usage. Can be overridden in a topic with the =%<nop>TEMPLATETOOLKIT{...}%= tag. | 58 | ={TToptions}= | Hash reference passed as =\%config= parameter to =Template->new()=. Refer to the TT documentation for details.%BR%Per default, the current topic's attachment directory is used as =INCLUDE_PATH=, and the =START_TAG= option is basically the familiar =[%=, but adjusted to take care for TWiki forced link/variable combinations. |57 | ={TToptions}= | Hash reference passed as =\%config= parameter to =Template->new()=. Refer to the TT documentation for details.%BR%Per default, the current topic's attachment directory is used as =INCLUDE_PATH=, and the =START_TAG= option is basically the familiar =[%=, but adjusted to take care for Foswiki forced link/variable combinations. | 59 58 60 59 ---++ Notes on Template Toolkit Syntax … … 64 63 =[%= and =%]=. As almost everything in TT this is configurable, 65 64 but the default delimiters are used quite frequently because they usually 66 don't occur in "normal text". _Usually_. In TWiki, there is a syntax65 don't occur in "normal text". _Usually_. In Foswiki, there is a syntax 67 66 construction which is quite popular, but makes TT croak: Forced links, 68 with an embedded TWiki variable. Example:67 with an embedded Foswiki macro. Example: 69 68 <verbatim> 70 69 [[%SYSTEMWEB%.%STATISTICSTOPIC%]] 71 70 </verbatim> 72 This is a valid TWiki link pointing to71 This is a valid Foswiki link pointing to 73 72 [[%SYSTEMWEB%.%STATISTICSTOPIC%]], but an invalid TT construct 74 73 =[% SYSTEMWEB%.%STATISTICSTOPIC %]= within an additional set of square … … 79 78 * It is good practice to write your TT constructs as =[% tt_directive %]=, 80 79 i.e. with surrounding spaces around directives. By doing so, 81 you'll make sure to never clash with a possible TWiki variablename80 you'll make sure to never clash with a possible Foswiki macro name 82 81 =%<nop>tt_directive%=. 83 * Separate TT stuff from heavy TWiki lifting or you'll get severe bracketiquotitis.82 * Separate TT stuff from heavy Foswiki lifting or you'll get severe bracketiquotitis. 84 83 * If you want to use different delimiters, define both ={TToptions}{START_TAG}= and 85 ={TToptions}{END_TAG}= in =$ TWiki::cfg{Plugins}{TemplateToolkitPlugin}=.84 ={TToptions}{END_TAG}= in =$Foswiki::cfg{Plugins}{TemplateToolkitPlugin}=. 86 85 * When writing TT wrappers for use with this plugin, keep in mind that they are 87 86 TT-expanded, but not TML-processed. … … 101 100 ---++ Security Considerations 102 101 103 Unlike in typical TT web applications, in a TWiki many people can edit102 Unlike in typical TT web applications, in a Foswiki many people can edit 104 103 the templates, and so they can introduce TT directives. To keep your 105 TWiki unharmed, some precautions should be made:104 Foswiki unharmed, some precautions should be made: 106 105 1 Do not enable EVAL_PERL (it is off per default). 107 106 1 Do not pass critical data structures like the configuration hash … … 114 113 115 114 If time permits, I'll try to: 116 * create a TWiki skin and a TT layout in parallel and run115 * create a Foswiki skin and a TT layout in parallel and run 117 116 benchmarks on both. 118 117 * document (and extend) configuration items 119 * Add a = TWiki= filter for TT templates so that wrappers can use TWiki variables118 * Add a =Foswiki= filter for TT templates so that wrappers can use Foswiki macros 120 119 * ... 121 120
Note: See TracChangeset
for help on using the changeset viewer.
