@@ -19,26 +19,26 @@ discard block |
||
19 | 19 | protected static $templatePath, |
20 | 20 | $globals = []; |
21 | 21 | |
22 | - public function __construct($path=null,$options=[]){ |
|
23 | - self::$templatePath = ($path ? rtrim($path,'/') : __DIR__) . '/'; |
|
22 | + public function __construct($path = null, $options = []) { |
|
23 | + self::$templatePath = ($path ? rtrim($path, '/') : __DIR__).'/'; |
|
24 | 24 | } |
25 | 25 | |
26 | - public static function exists($path){ |
|
27 | - return is_file(self::$templatePath . $path . static::EXTENSION); |
|
26 | + public static function exists($path) { |
|
27 | + return is_file(self::$templatePath.$path.static::EXTENSION); |
|
28 | 28 | } |
29 | 29 | |
30 | - public static function addGlobal($key,$val){ |
|
30 | + public static function addGlobal($key, $val) { |
|
31 | 31 | self::$globals[$key] = $val; |
32 | 32 | } |
33 | 33 | |
34 | - public static function addGlobals(array $defs){ |
|
35 | - foreach ((array)$defs as $key=>$val) { |
|
34 | + public static function addGlobals(array $defs) { |
|
35 | + foreach ((array) $defs as $key=>$val) { |
|
36 | 36 | self::$globals[$key] = $val; |
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
40 | - public function render($template, $data=[]){ |
|
41 | - $template_path = self::$templatePath . trim($template,'/') . static::EXTENSION; |
|
40 | + public function render($template, $data = []) { |
|
41 | + $template_path = self::$templatePath.trim($template, '/').static::EXTENSION; |
|
42 | 42 | $sandbox = function() use ($template_path){ |
43 | 43 | ob_start(); |
44 | 44 | include($template_path); |
@@ -56,19 +56,19 @@ discard block |
||
56 | 56 | class PHPContext { |
57 | 57 | protected $data = []; |
58 | 58 | |
59 | - public function __construct($data=[], $path=null){ |
|
59 | + public function __construct($data = [], $path = null) { |
|
60 | 60 | $this->data = $data; |
61 | 61 | } |
62 | 62 | |
63 | - public function partial($template, $vars=[]){ |
|
64 | - return \View::from($template,array_merge($this->data,$vars)); |
|
63 | + public function partial($template, $vars = []) { |
|
64 | + return \View::from($template, array_merge($this->data, $vars)); |
|
65 | 65 | } |
66 | 66 | |
67 | - public function __isset($n){ return true; } |
|
67 | + public function __isset($n) { return true;} |
|
68 | 68 | |
69 | - public function __unset($n){} |
|
69 | + public function __unset($n) {} |
|
70 | 70 | |
71 | - public function __get($n){ |
|
71 | + public function __get($n) { |
|
72 | 72 | return empty($this->data[$n]) ? '' : $this->data[$n]; |
73 | 73 | } |
74 | 74 | } |