-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimplate.php
More file actions
executable file
·49 lines (40 loc) · 1.25 KB
/
Simplate.php
File metadata and controls
executable file
·49 lines (40 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
* Renderer_Simplate
*
* @category Addon
* @package addon.renderer
* @author Hamanaka Kazuhiro <hamanaka.kazuhiro@sabel.jp>
* @copyright 2004-2008 Mori Reo <mori.reo@sabel.jp>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
class Renderer_Simplate extends Sabel_View_Renderer
{
private $simplate = null;
public function initialize()
{
$simplate = new simplate();
$simplate->compile_dir = COMPILE_DIR_PATH . DS;
$simplate->lazy_check = true;
if ((ENVIRONMENT & PRODUCTION) > 0) {
$simplate->caching = true;
$simplate->cache_dir = CACHE_DIR_PATH . DS;
$simplate->cache_lifetime = 600;
}
$this->simplate = $simplate;
}
public function rendering($_tpl_contents, $_tpl_values, $_tpl_path = null)
{
$simplate = $this->simplate;
if ($_tpl_path === null || !is_file($_tpl_path)) {
$hash = $this->createHash($_tpl_contents);
$_tpl_path = COMPILE_DIR_PATH . DS . $hash;
file_put_contents($_tpl_path, $_tpl_contents);
}
$simplate->template_dir = dirname($_tpl_path);
foreach ($_tpl_values as $k => $v) {
$simplate->assign($k, $v);
}
return $simplate->fetch(basename($_tpl_path));
}
}