This document describes template language of IPF framework.
+ Templates are placed in 'templates' directories of project or application.
+
=[ ]?= -- optional code
=[ ]*= -- code can be repeated zero or more times.
+ =template_tags= -- additional template tags
+ =template_modifiers= -- additional template modifiers
+ =template_context_processors= -- list of context processors
- + =template_dirs= -- list of directories to look for template files. By default it contains 'templates' folder in project directory and 'templates' folder in IPF_Admin application (when it is enabled).
+ =debug= -- forces to recompile template before each rendering
if (!is_array(IPF::$settings['applications']))
throw new IPF_Exception_Settings('applications must be array of string');
- if (!isset(IPF::$settings['template_dirs'])){
- IPF::$settings['template_dirs'] = array();
- IPF::$settings['template_dirs'][] = IPF::$settings['project_path'].DIRECTORY_SEPARATOR.'templates';
- if (array_search('IPF_Admin',IPF::$settings['applications']))
- IPF::$settings['template_dirs'][] = IPF::$settings['ipf_path'].DIRECTORY_SEPARATOR.'ipf'.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'templates';
- }
-
if (!isset(IPF::$settings['admin_title'])){
IPF::$settings['admin_title'] = 'IPF Administration';
}
public static function getDefault()
{
- if (!self::$defaultEnvironment)
- self::$defaultEnvironment = new IPF_Template_Environment_FileSystem(IPF::get('template_dirs'), IPF::get('tmp'));
+ if (!self::$defaultEnvironment) {
+ $dirs = array();
+
+ $projectTemplates = IPF::get('project_path') . '/templates';
+ if (is_dir($projectTemplates))
+ $dirs[] = $projectTemplates;
+
+ foreach (IPF_Project::getInstance()->appList() as $app) {
+ $applicationTemplates = $app->getPath() . 'templates';
+ if (is_dir($applicationTemplates))
+ $dirs[] = $applicationTemplates;
+ }
+
+ self::$defaultEnvironment = new IPF_Template_Environment_FileSystem($dirs, IPF::get('tmp'));
+ }
return self::$defaultEnvironment;
}
}