-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.php
More file actions
42 lines (32 loc) · 890 Bytes
/
template.php
File metadata and controls
42 lines (32 loc) · 890 Bytes
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
<?php
class Template {
public $path;
public function __construct($template_path){
$this->path = $template_path;
}
/**
* Load a template from within a template
*/
public function render($path, array $args = array()){
$temp = new Template($this->path);
return $temp->load($path, $args);
}
/**
* load a template from another class
*/
public function load($path, array $arguments = array()){
$this->arguments = $arguments;
ob_start();
$file = sprintf('%s/%s', $this->path, $path);
require $file;
$content = ob_get_contents();
ob_end_clean();
return $content;
}
public function get($arg, $default = null){
if(array_key_exists($arg, $this->arguments)){
return $this->arguments[$arg];
}
return $default;
}
}