You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.5 KiB

3 years ago
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006-2014 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: liu21st <liu21st@gmail.com>
  10. // +----------------------------------------------------------------------
  11. namespace Think\Template\Driver;
  12. /**
  13. * EaseTemplate模板引擎驱动
  14. */
  15. class Ease {
  16. /**
  17. * 渲染模板输出
  18. * @access public
  19. * @param string $templateFile 模板文件名
  20. * @param array $var 模板变量
  21. * @return void
  22. */
  23. public function fetch($templateFile,$var) {
  24. $templateFile = substr($templateFile,strlen(THEME_PATH),-5);
  25. $CacheDir = substr(CACHE_PATH,0,-1);
  26. $TemplateDir = substr(THEME_PATH,0,-1);
  27. vendor('EaseTemplate.template#ease');
  28. $config = array(
  29. 'CacheDir' => $CacheDir,
  30. 'TemplateDir' => $TemplateDir,
  31. 'TplType' => 'html'
  32. );
  33. if(C('TMPL_ENGINE_CONFIG')) {
  34. $config = array_merge($config,C('TMPL_ENGINE_CONFIG'));
  35. }
  36. $tpl = new \EaseTemplate($config);
  37. $tpl->set_var($var);
  38. $tpl->set_file($templateFile);
  39. $tpl->p();
  40. }
  41. }