Template Lite - the faster compiling PHP template engine

Variables


$template_dir

This is a string that tells Template Lite what directory to look for the templates in. You can refer to subdirectories of this folder, too, but this is the base folder for templates.

The default is the templates subdirectory of the template_lite folder.


$config_dir

This is a string that tells Template Lite what directory to look for config files in.

The default is the templates subdirectory of the template_lite folder.


$compile_dir

This is a string that tells Template Lite what directory compiled files will be saved to. Whatever directory this is must have write permissions available for the webserver or else compiled files cannot be saved.

The default is the compiled subdirectory of the template_lite folder.


$cache_dir

This is a string that tells Template Lite what directory cached files will be saved to. Whatever directory this is must have write permissions available for the webserver or else cached files cannot be saved.

The default is the cached subdirectory of the template_lite folder.


$plugins_dir

This is an array that tells Template Lite what directories plugin files will be loaded from. There can be more than one plugin directory.

The default is the plugins subdirectory of the template_lite folder.

Example

	PHP
	=============================
	$tpl->plugins_dir = array("plugins", "myplugins", "/home/www/mysite/templateplugins");
	
You must have a plugins element in your plugins_dir array and it should always be the first element in the array. In the above example Template Lite will seach for a plugin in each of the above directories one after the other. If the plugin cannot be found an error is generated.


$left_delimiter

This is the left delimiter used by the template engine. The default is "{".


$right_delimiter

This is the right delimiter used by the template engine. The default is "}".


$cache

Tells Template Lite whether or not to cache the output of the templates. By default this is set to false or disabled. If your templates generate content that rarely changes, or you are looking to increase the speed at which your templates are generated, it is advisable to turn on caching, as your templates will load significantly faster. You can have multiple caches for the same page, but this is described in the caching appendix. It is important to reset the $cache_lifetime variable when beginning to work with a page that is being cached or else the page will not be cached. Before any cached file is loaded, it will be checked to see if the original template has changed, or if the cache is out of date. Also, if $force_compile is enabled, then the cache will be regenerated each time the page is loaded.


$cache_lifetime

This is the length of time in seconds that a template cache is valid. Once this time has expired, the cache will be regenerated. $cache must be set to true for $cache_lifetime to have any valid meaning. A value of 0, the default, will always regenerate the cache, which is good for testing purposes only. To disable caching, you should always set $cache to false. If $force_compile is set to true, then the cache files will be regenerated every time the page is loaded, also effectively disabling caching. You can clear all cached files by calling clear_cached().


$force_compile

If this is set to true then each page will be recompiled upon every viewing. This is horribly inefficient and highly discouraged, but is useful for testing your templates.


$config_overwrite

When loading config files either from your PHP script or from your templates themselves, this variable can change the behavior of the loading process. When set to true, config variables with the same name will overwrite each other. If set to false, config variables of the same name will be pushed into a numerically indexed array. The default is to not overwrite. This is for storing arrays in config files, simply by listing the same config file multiple times.


$config_booleanize

When this is set to true, a config value of true or yes or on or 1 will be translated to mean "true". At the same time, a config value of false or no or off or 0 will be translated to "false". This is true by default.


$config_fix_new_lines

If set to true, Mac and DOS newlines, \r and \r\n, respectively, in config files are converted to \n when they are parsed. This is true by default.


$config_read_hidden

If set to true, hidden sections, those are sections that begin with a period, such as [.secret], can be and are read from config files into templates. Hidden sections are usually meant to store things such as database passwords and thus, this is typically false. The default is set to true.


$default_modifiers

This is an array of modifiers to apply to every variable in a template. For example, to HTML-escape every variable by default, use array('escape:"htmlall"'); To make a variable exempt from default modifiers, pass the special "templatelite" modifier with a parameter value of "nodefaults" modifier to it, such as {$var|templatelite:nodefaults}.


$debugging

This enabled very minimal debugging through the tracking of the templates compiled and the compile time into the $templatelite_object->_templatelite_debug_info array. If you have any applications that use the $smarty->_smarty_debug_info variable you will need to edit the variable name either in your application or in the class.template.php program to match. Support for the Debug Console is supported using a debug.tpl file located in the internal directory. Support for changing the location of the debug.tpl file through the $templatelite_object->debug_tpl variable is not supported. If you wish to use a different debug console you need to change the debug.tpl file in the internal directory. The Debug Console is not displayed if you are using the fetch function.


Constants


TEMPLATE_LITE_DIR

This is the full system path to the location of the Template Lite class files. If path is not set, then Template Lite will determine the appropriate path automatically. If you manually set the path you MUST end the path with a forward slash.

Example

	EXAMPLE PHP
	=============================
	// linux path
	define('TEMPLATE_LITE_DIR', '/usr/local/lib/php/template_lite/src/');


	// windows path
	define('TEMPLATE_LITE_DIR', 'c:/webroot/libs/template_lite/src/');
	


Home