function TemplateLite($templateFile, $templateVar, $charset, $varPrefix = '') { $templateFile = substr($templateFile, strlen(TMPL_PATH)); include_once "class.template.php"; $tpl = new Template_Lite(); $tpl->template_dir = TMPL_PATH; $tpl->compile_dir = CACHE_PATH; $tpl->cache_dir = TEMP_PATH; $tpl->assign($templateVar); $tpl->display($templateFile); return; }
function render_template($template_name, $assign_vars = array()) { // Initialize the template object. $tpl = new Template_Lite(); // template directory $tpl->template_dir = TEMPLATE_PATH; // compile directory $tpl->compile_dir = COMPILED_TEMPLATE_PATH; // loop over the vars, assigning each. foreach ($assign_vars as $lname => $lvalue) { $tpl->assign($lname, $lvalue); } // call the template $rendered = $tpl->fetch($template_name); return $rendered; }
/** * @see RO_Flow_Work::_run() * * @return RO_Flow_Work */ protected function _run() { $this->_setNext('NEXT'); if (!isset($this->_data['_VIEW_DATA_'])) { return; } $data = $this->_data['_VIEW_DATA_']; $tpl = str_replace('_', DIRECTORY_SEPARATOR, $this->_data['_VIEW_']) . $this->_params['suffix']; $tplite = new Template_Lite(); $tplite->template_dir = $this->_params['tpl_path']; $tplite->compile_dir = $this->_params['tplc_path']; $tplite->cache = false; $tplite->force_compile = true; $tplite->assign($data); $tplite->display($tpl); }
/** * 渲染模板输出 * @access public * @param string $templateFile 模板文件名 * @param array $var 模板变量 * @return void */ public function fetch($templateFile, $var) { vendor("TemplateLite.class#template"); $templateFile = substr($templateFile, strlen(THEME_PATH)); $tpl = new \Template_Lite(); $tpl->template_dir = THEME_PATH; $tpl->compile_dir = CACHE_PATH; $tpl->cache_dir = TEMP_PATH; if (C('TMPL_ENGINE_CONFIG')) { $config = C('TMPL_ENGINE_CONFIG'); foreach ($config as $key => $val) { $tpl->{$key} = $val; } } $tpl->assign($var); $tpl->display($templateFile); }
<?php /* * 74cms 初始化smarty引擎 * ============================================================================ * 版权所有: 骑士网络,并保留所有权利。 * 网站地址: http://www.74cms.com; * ---------------------------------------------------------------------------- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和 * 使用;不允许对程序代码以任何形式任何目的的再发布。 * ============================================================================ */ if (!defined('IN_QISHI')) { die('Access Denied!'); } include_once QISHI_ROOT_PATH . 'include/template_lite/class.template.php'; $smarty = new Template_Lite(); $smarty->compile_dir = QISHI_ROOT_PATH . 'temp/templates_c'; $smarty->template_dir = ADMIN_ROOT_PATH . "templates/default/"; $smarty->cache_dir = QISHI_ROOT_PATH . 'temp/caches'; $smarty->reserved_template_varname = "smarty"; $smarty->cache = false; $smarty->left_delimiter = "{#"; $smarty->right_delimiter = "#}"; $smarty->force_compile = false; $smarty->assign('_PLUG', $_PLUG); $smarty->assign('QISHI', $_CFG); $smarty->assign('QISHI_VERSION', QISHI_VERSION . "." . QISHI_RELEASE);
<?php /* * 74cms 初始化模版引擎 * ============================================================================ * 版权所有: 骑士网络,并保留所有权利。 * 网站地址: http://www.74cms.com; * ---------------------------------------------------------------------------- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和 * 使用;不允许对程序代码以任何形式任何目的的再发布。 * ============================================================================ */ if (!defined('IN_QISHI')) { die('Access Denied!'); } include_once QISHI_ROOT_PATH . 'include/template_lite/class.template.php'; $smarty = new Template_Lite(); $smarty->cache_dir = QISHI_ROOT_PATH . 'temp/caches/' . $_CFG['template_dir']; $smarty->compile_dir = QISHI_ROOT_PATH . 'temp/templates_c/' . $_CFG['template_dir']; $smarty->template_dir = QISHI_ROOT_PATH . 'templates/' . $_CFG['template_dir']; $smarty->reserved_template_varname = "smarty"; $smarty->left_delimiter = "{#"; $smarty->right_delimiter = "#}"; $smarty->force_compile = false; $smarty->assign('_PLUG', $_PLUG); $smarty->assign('QISHI', $_CFG); $smarty->assign('page_select', $page_select);
<?php $timeparts = explode(" ", microtime()); $starttime = $timeparts[1] . substr($timeparts[0], 1); require "../src/class.template.php"; $tpl = new Template_Lite(); $tpl->force_compile = true; $tpl->compile_check = true; $tpl->cache = false; $tpl->cache_lifetime = 3600; $tpl->config_overwrite = false; $tpl->assign("Name", "Fred Irving Johnathan Bradley Peppergill"); $tpl->assign("FirstName", array("John", "Mary", "James", "Henry")); $tpl->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"), array("phone" => "555-5555", "fax" => "555-4444", "cell" => "555-3333"))); $tpl->assign("bold", array("up", "down", "left", "right")); $tpl->assign("lala", array("up" => "first entry", "down" => "last entry")); $tpl->display("index.tpl"); $timeparts = explode(" ", microtime()); $endtime = $timeparts[1] . substr($timeparts[0], 1); echo bcsub($endtime, $starttime, 6);