It's very nice. Click to hide the menu and go all widescreen! Back You can't go back. The evaltt filter is provided as an alias for eval. The perl filter evaluates the block as Perl code.
Thus, the previous example could have been written in the more verbose form:. The evalperl filter is provided as an alias for perl for backwards compatibility. The binmode option can be passed as either a named parameter or a single argument to set STDOUT to binary mode see the binmode perl function. See the null filter below for an example. The null filter prints nothing. This is useful for plugins whose methods return values that you don't want to appear in the output.
Rather than assigning every plugin method call to a dummy variable to silence it, you can wrap the block in a null filter:. Notice the use of the stdout filter to ensure that a particular expression generates output to STDOUT in this case in binary mode. It's very nice. Click to hide the menu and go all widescreen! Contents Top Close Open.
For more information on module installation, please visit the detailed CPAN module installation guide. You can access individual fields via the field variable. For a field named The field data is in All Rights Reserved.
Enables general debugging messages for the Template::Filters module. This flag causes the Template::Parser to generate debugging messages that show the Perl code generated by parsing and compiling each template. This option causes the Template Toolkit to throw an ' undef ' error whenever it encounters an undefined variable value.
This option causes the Template Toolkit to generate comments indicating the source file, line and original text of each directive in the template. This option causes all debug messages that aren't newline terminated to have the file name and line number of the caller appended to them. Notice how the format is single quoted to prevent Perl from interpolating those tokens as variables.
The Template::Provider module caches compiled templates to avoid the need to re-parse template files or blocks each time they are used. When set to any positive value, the cache will be limited to storing no more than that number of compiled templates.
When a new template is loaded and compiled and the cache is full i. As well as caching templates as they are found, the Template::Provider also implements negative caching to keep track of templates that are not found. This allows the provider to quickly decline a request for a template that it has previously failed to locate, saving the effort of going to look for it again.
This value can be set to control how long the Template::Provider will keep a template cached in memory before checking to see if the source template has changed.
The default value is 1 second. You'll probably want to set this to a higher value if you're running the Template Toolkit inside a persistent web server application e. For example, set it to 60 and the provider will only look for changes to templates once a minute at most. However, during development or any time you're making frequent changes to templates you'll probably want to keep it set to a low value so that you don't have to wait for the provider to notice that your templates have changed.
From version 2 onwards, the Template Toolkit has the ability to compile templates to Perl code and save them to disk for subsequent use i. It is undefined by default and no attempt will be made to read or write any compiled template files.
The Template Toolkit will automatically reload and reuse compiled files when it finds them on disk. If the corresponding source file has been modified since the compiled version as written, then it will load and re-compile the source and write a new compiled version to disk.
This form of cache persistence offers significant benefits in terms of time and resources required to reload templates. Compiled templates can be reloaded by a simple call to Perl's require , leaving Perl to handle all the parsing and compilation. This is a Good Thing. This example:. On Win32 platforms a filename may by prefixed by a drive letter and colon. For example:. A number of standard plugins are defined e. The recommended convention is to specify these plugin names in lower case.
The Template Toolkit first looks for an exact case-sensitive match and then tries the lower case conversion of the name specified. The USE directive is used to create plugin objects and does so by calling the plugin method on the current Template::Context object. The context then calls the load class method which should return the class name default and general case or a prototype object against which the new method can be called to instantiate individual plugin objects.
This allows regular Perl modules i. They must provide a new class method for instantiating objects but it will not receive a reference to the context as the first argument. Plugin modules should provide a load class method or inherit the default one from the Template::Plugin base class which is called the first time the plugin is loaded. Regular Perl modules need not. In all other respects, regular Perl objects and Template Toolkit plugins are identical.
If a particular Perl module does not conform to the common, but not unilateral, new constructor convention then a simple plugin wrapper can be written to interface to it. These are added to the standard filters which are available by default. Filters specified via this option will mask any standard filters of the same name.
The corresponding value should contain a reference to an array containing a subroutine reference and a flag which indicates if the filter is static 0 or dynamic 1.
0コメント