Vous êtes connecté en tant que anonymous Se Deconnecter
Browse code

Application modulaire fonctionnelle !

Emmanuel ROY authored on 12/08/2019 15:10:25
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,135 +0,0 @@
1
-<?php declare(strict_types=1);
2
-/**
3
- * Part of Windwalker project.
4
- *
5
- * @copyright  Copyright (C) 2019 LYRASOFT.
6
- * @license    LGPL-2.0-or-later
7
- */
8
-
9
-namespace Windwalker\Renderer;
10
-
11
-/**
12
- * The MustacheRenderer class.
13
- *
14
- * @since  2.0
15
- */
16
-class MustacheRenderer extends AbstractEngineRenderer
17
-{
18
-    /**
19
-     * Property engine.
20
-     *
21
-     * @var \Mustache_Engine
22
-     */
23
-    protected $engine;
24
-
25
-    /**
26
-     * Property loader.
27
-     *
28
-     * @var \Mustache_Loader
29
-     */
30
-    protected $loader;
31
-
32
-    /**
33
-     * render
34
-     *
35
-     * @param string $file
36
-     * @param array  $data
37
-     *
38
-     * @return  string
39
-     */
40
-    public function render($file, $data = [])
41
-    {
42
-        $engine = $this->getEngine();
43
-
44
-        $path = $this->findFile($file);
45
-
46
-        $engine->setLoader($this->getLoader(dirname($path)));
47
-
48
-        return $engine->render($file, $data);
49
-    }
50
-
51
-    /**
52
-     * findFile
53
-     *
54
-     * @param string $file
55
-     * @param string $ext
56
-     *
57
-     * @return  string
58
-     */
59
-    public function findFile($file, $ext = '')
60
-    {
61
-        $ext = $ext ?: $this->config->get('extension', 'mustache');
62
-
63
-        return parent::findFile($file, $ext);
64
-    }
65
-
66
-    /**
67
-     * Method to get property Engine
68
-     *
69
-     * @param   boolean $new
70
-     *
71
-     * @return  \Mustache_Engine
72
-     */
73
-    public function getEngine($new = false)
74
-    {
75
-        if (!$this->engine || $new) {
76
-            $this->engine = new \Mustache_Engine($this->config->get('options', []));
77
-        }
78
-
79
-        return $this->engine;
80
-    }
81
-
82
-    /**
83
-     * Method to set property engine
84
-     *
85
-     * @param   \Mustache_Engine $engine
86
-     *
87
-     * @return  static  Return self to support chaining.
88
-     */
89
-    public function setEngine($engine)
90
-    {
91
-        if (!($engine instanceof \Mustache_Engine)) {
92
-            throw new \InvalidArgumentException('Engine object should be Mustache_Engine');
93
-        }
94
-
95
-        $this->engine = $engine;
96
-
97
-        return $this;
98
-    }
99
-
100
-    /**
101
-     * Method to get property Loader
102
-     *
103
-     * @param string $path
104
-     *
105
-     * @return  \Mustache_Loader
106
-     */
107
-    public function getLoader($path = null)
108
-    {
109
-        if (!$this->loader) {
110
-            $options = [
111
-                // 'extension' => '.html'
112
-            ];
113
-
114
-            $options = array_merge($options, (array) $this->config->get('loader_options', []));
115
-
116
-            $this->loader = new \Mustache_Loader_FilesystemLoader($path, $options);
117
-        }
118
-
119
-        return $this->loader;
120
-    }
121
-
122
-    /**
123
-     * Method to set property loader
124
-     *
125
-     * @param   \Mustache_Loader $loader
126
-     *
127
-     * @return  static  Return self to support chaining.
128
-     */
129
-    public function setLoader($loader)
130
-    {
131
-        $this->loader = $loader;
132
-
133
-        return $this;
134
-    }
135
-}
Browse code

initial commit

Emmanuel ROY authored on 09/08/2019 08:39:02
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,135 @@
1
+<?php declare(strict_types=1);
2
+/**
3
+ * Part of Windwalker project.
4
+ *
5
+ * @copyright  Copyright (C) 2019 LYRASOFT.
6
+ * @license    LGPL-2.0-or-later
7
+ */
8
+
9
+namespace Windwalker\Renderer;
10
+
11
+/**
12
+ * The MustacheRenderer class.
13
+ *
14
+ * @since  2.0
15
+ */
16
+class MustacheRenderer extends AbstractEngineRenderer
17
+{
18
+    /**
19
+     * Property engine.
20
+     *
21
+     * @var \Mustache_Engine
22
+     */
23
+    protected $engine;
24
+
25
+    /**
26
+     * Property loader.
27
+     *
28
+     * @var \Mustache_Loader
29
+     */
30
+    protected $loader;
31
+
32
+    /**
33
+     * render
34
+     *
35
+     * @param string $file
36
+     * @param array  $data
37
+     *
38
+     * @return  string
39
+     */
40
+    public function render($file, $data = [])
41
+    {
42
+        $engine = $this->getEngine();
43
+
44
+        $path = $this->findFile($file);
45
+
46
+        $engine->setLoader($this->getLoader(dirname($path)));
47
+
48
+        return $engine->render($file, $data);
49
+    }
50
+
51
+    /**
52
+     * findFile
53
+     *
54
+     * @param string $file
55
+     * @param string $ext
56
+     *
57
+     * @return  string
58
+     */
59
+    public function findFile($file, $ext = '')
60
+    {
61
+        $ext = $ext ?: $this->config->get('extension', 'mustache');
62
+
63
+        return parent::findFile($file, $ext);
64
+    }
65
+
66
+    /**
67
+     * Method to get property Engine
68
+     *
69
+     * @param   boolean $new
70
+     *
71
+     * @return  \Mustache_Engine
72
+     */
73
+    public function getEngine($new = false)
74
+    {
75
+        if (!$this->engine || $new) {
76
+            $this->engine = new \Mustache_Engine($this->config->get('options', []));
77
+        }
78
+
79
+        return $this->engine;
80
+    }
81
+
82
+    /**
83
+     * Method to set property engine
84
+     *
85
+     * @param   \Mustache_Engine $engine
86
+     *
87
+     * @return  static  Return self to support chaining.
88
+     */
89
+    public function setEngine($engine)
90
+    {
91
+        if (!($engine instanceof \Mustache_Engine)) {
92
+            throw new \InvalidArgumentException('Engine object should be Mustache_Engine');
93
+        }
94
+
95
+        $this->engine = $engine;
96
+
97
+        return $this;
98
+    }
99
+
100
+    /**
101
+     * Method to get property Loader
102
+     *
103
+     * @param string $path
104
+     *
105
+     * @return  \Mustache_Loader
106
+     */
107
+    public function getLoader($path = null)
108
+    {
109
+        if (!$this->loader) {
110
+            $options = [
111
+                // 'extension' => '.html'
112
+            ];
113
+
114
+            $options = array_merge($options, (array) $this->config->get('loader_options', []));
115
+
116
+            $this->loader = new \Mustache_Loader_FilesystemLoader($path, $options);
117
+        }
118
+
119
+        return $this->loader;
120
+    }
121
+
122
+    /**
123
+     * Method to set property loader
124
+     *
125
+     * @param   \Mustache_Loader $loader
126
+     *
127
+     * @return  static  Return self to support chaining.
128
+     */
129
+    public function setLoader($loader)
130
+    {
131
+        $this->loader = $loader;
132
+
133
+        return $this;
134
+    }
135
+}