@@ -12,9 +12,10 @@ |
||
12 | 12 | echo minifyOutput($render); |
13 | 13 | } |
14 | 14 | protected function overlayTag( $_page ) { |
15 | - foreach($this->tags as $key => $value) |
|
16 | - if(!is_array($value)) |
|
15 | + foreach($this->tags as $key => $value) { |
|
16 | + if(!is_array($value)) |
|
17 | 17 | $_page = str_replace("<_${key}_>", "$value", $_page); |
18 | + } |
|
18 | 19 | return $_page; |
19 | 20 | } |
20 | 21 | } |
@@ -6,24 +6,24 @@ |
||
6 | 6 | public function __construct() { |
7 | 7 | parent::__construct(); |
8 | 8 | } |
9 | - public function init( $_page ) { |
|
9 | + public function init($_page) { |
|
10 | 10 | $this->tags = $_page->tags; |
11 | 11 | } |
12 | - public function draw( $_template ) { |
|
12 | + public function draw($_template) { |
|
13 | 13 | $page = ""; |
14 | - $extension = explode(".",$_template); |
|
15 | - $extension = $extension[count($extension)-1]; |
|
14 | + $extension = explode(".", $_template); |
|
15 | + $extension = $extension[count($extension) - 1]; |
|
16 | 16 | $page = $this->parsingFile($_template, $extension); |
17 | 17 | $render = $this->overlayTag($page); |
18 | 18 | echo minifyOutput($render); |
19 | 19 | } |
20 | - protected function overlayTag( $_page ) { |
|
21 | - foreach($this->tags as $key => $value) |
|
22 | - if(!is_array($value)) |
|
20 | + protected function overlayTag($_page) { |
|
21 | + foreach ($this->tags as $key => $value) |
|
22 | + if (!is_array($value)) |
|
23 | 23 | $_page = str_replace("<_${key}_>", "$value", $_page); |
24 | 24 | return $_page; |
25 | 25 | } |
26 | - protected function parsingFile( $_file, $_type = "html" ) { |
|
26 | + protected function parsingFile($_file, $_type = "html") { |
|
27 | 27 | switch ($_type) { |
28 | 28 | case 'pug': |
29 | 29 | case 'jade': |
@@ -16,6 +16,9 @@ |
||
16 | 16 | return jBlockFileMan($_path, $extension, $_parameters); |
17 | 17 | } |
18 | 18 | |
19 | + /** |
|
20 | + * @param string $_type |
|
21 | + */ |
|
19 | 22 | function jBlockFileMan( $_path, $_type, $_parameters = [] ) { |
20 | 23 | $temp = file_get_contents($_path); |
21 | 24 | return jBlockParsing($_type, $temp, $_parameters); |
@@ -5,28 +5,28 @@ discard block |
||
5 | 5 | return ob_start(); |
6 | 6 | } |
7 | 7 | |
8 | - function jBlockClose( $_type = "html", $_parameters = [] ) { |
|
8 | + function jBlockClose($_type = "html", $_parameters = []) { |
|
9 | 9 | return jBlockEnd($_type, $_parameters); |
10 | 10 | } |
11 | 11 | |
12 | - function jBlockFile( $_path, $_parameters = [] ) { |
|
12 | + function jBlockFile($_path, $_parameters = []) { |
|
13 | 13 | $extension = explode(".", $_path); |
14 | - $extension = $extension[count($extension)-1]; |
|
14 | + $extension = $extension[count($extension) - 1]; |
|
15 | 15 | $extension = strtolower($extension); |
16 | 16 | return jBlockFileMan($_path, $extension, $_parameters); |
17 | 17 | } |
18 | 18 | |
19 | - function jBlockFileMan( $_path, $_type, $_parameters = [] ) { |
|
19 | + function jBlockFileMan($_path, $_type, $_parameters = []) { |
|
20 | 20 | $temp = file_get_contents($_path); |
21 | 21 | return jBlockParsing($_type, $temp, $_parameters); |
22 | 22 | } |
23 | 23 | |
24 | - function jBlockEnd( $_type = "html", $_parameters = [] ) { |
|
24 | + function jBlockEnd($_type = "html", $_parameters = []) { |
|
25 | 25 | $text = ob_get_clean(); |
26 | 26 | return jBlockParsing($_type, $text, $_parameters); |
27 | 27 | } |
28 | 28 | |
29 | - function jBlockParsing( $_type = "html", $_string = "", $_parameters = [] ) { |
|
29 | + function jBlockParsing($_type = "html", $_string = "", $_parameters = []) { |
|
30 | 30 | switch ($_type) { |
31 | 31 | case "pug": |
32 | 32 | case "jade": |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | function minifyOutput($_buffer) { |
52 | - $search = array ( '/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s' ); |
|
53 | - $replace = array ( '>', '<', '\\1' ); |
|
54 | - if (preg_match("/\<html/i",$_buffer) == 1 && preg_match("/\<\/html\>/i",$_buffer) == 1) |
|
52 | + $search = array('/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s'); |
|
53 | + $replace = array('>', '<', '\\1'); |
|
54 | + if (preg_match("/\<html/i", $_buffer) == 1 && preg_match("/\<\/html\>/i", $_buffer) == 1) |
|
55 | 55 | $_buffer = preg_replace($search, $replace, utf8_decode($_buffer)); |
56 | 56 | return utf8_encode($_buffer); |
57 | 57 | } |
@@ -8,6 +8,10 @@ |
||
8 | 8 | public function drawFile( $_file, $_parameters = [] ) { |
9 | 9 | return $this->draw($_file, $_parameters); |
10 | 10 | } |
11 | + |
|
12 | + /** |
|
13 | + * @param string $_text |
|
14 | + */ |
|
11 | 15 | public function drawText( $_text, $_parameters = [] ) { |
12 | 16 | return $this->draw(trim($_text), $_parameters); |
13 | 17 | } |
@@ -5,13 +5,13 @@ |
||
5 | 5 | public function __construct() { |
6 | 6 | parent::__construct(); |
7 | 7 | } |
8 | - public function drawFile( $_file, $_parameters = [] ) { |
|
8 | + public function drawFile($_file, $_parameters = []) { |
|
9 | 9 | return $this->draw($_file, $_parameters); |
10 | 10 | } |
11 | - public function drawText( $_text, $_parameters = [] ) { |
|
11 | + public function drawText($_text, $_parameters = []) { |
|
12 | 12 | return $this->draw(trim($_text), $_parameters); |
13 | 13 | } |
14 | - public function draw( $_text, $_parameters = [] ) { |
|
14 | + public function draw($_text, $_parameters = []) { |
|
15 | 15 | $pug = new Pug\Pug(); |
16 | 16 | $page = $pug->render($_text, $_parameters); |
17 | 17 | return $page; |
@@ -14,6 +14,10 @@ |
||
14 | 14 | $page = $template->render($_parameters); |
15 | 15 | return $page; |
16 | 16 | } |
17 | + |
|
18 | + /** |
|
19 | + * @param string $_text |
|
20 | + */ |
|
17 | 21 | public function drawText( $_text, $_parameters = [] ) { |
18 | 22 | $loader = new Twig_Loader_Array([ |
19 | 23 | 'index' => $_text |
@@ -5,16 +5,16 @@ |
||
5 | 5 | public function __construct() { |
6 | 6 | parent::__construct(); |
7 | 7 | } |
8 | - public function drawFile( $_file, $_parameters = [] ) { |
|
9 | - $loader = new Twig_Loader_Filesystem('bundles/views'); |
|
10 | - $twig = new Twig_Environment( $loader, [ |
|
8 | + public function drawFile($_file, $_parameters = []) { |
|
9 | + $loader = new Twig_Loader_Filesystem('bundles/views'); |
|
10 | + $twig = new Twig_Environment($loader, [ |
|
11 | 11 | 'cache' => 'bundles/views', |
12 | 12 | ]); |
13 | 13 | $template = $twig->loadTemplate($_text); |
14 | 14 | $page = $template->render($_parameters); |
15 | 15 | return $page; |
16 | 16 | } |
17 | - public function drawText( $_text, $_parameters = [] ) { |
|
17 | + public function drawText($_text, $_parameters = []) { |
|
18 | 18 | $loader = new Twig_Loader_Array([ |
19 | 19 | 'index' => $_text |
20 | 20 | ]); |