1 | <?php |
||
41 | class PhpEngine extends AbstractEngine |
||
42 | { |
||
43 | private $helpersLoader; |
||
44 | private $janitor; |
||
45 | |||
46 | public function __construct(HelpersLoader $helpersLoader, Janitor $janitor) |
||
50 | |||
51 | function partial($template, $templateData = array()) |
||
55 | |||
56 | function unescape($item) |
||
64 | |||
65 | /** |
||
66 | * Passes the data to be rendered to the template engine instance. |
||
67 | */ |
||
68 | public function renderFromFileTemplate(string $filePath, array $data) : string |
||
91 | |||
92 | /** |
||
93 | * Passes a template string and data to be rendered to the template engine |
||
94 | * instance. |
||
95 | */ |
||
96 | public function renderFromStringTemplate(string $string, array $data) : string |
||
102 | |||
103 | // public function generate($templateVariables) |
||
104 | // { |
||
105 | // // Escape each variable by passing it through the variable class. |
||
106 | // // Users would have to unescape them by calling the escape method directly |
||
107 | // // on the variable. |
||
108 | // foreach ($templateVariables as $_key => $_value) { |
||
109 | // $$_key = php\Variable::initialize($_value); |
||
110 | // } |
||
111 | // |
||
112 | // // Expose helpers |
||
113 | // $helpers = $this->getHelpersLoader(); |
||
114 | // |
||
115 | // // Start trapping the output buffer and include the PHP template for |
||
116 | // // execution. |
||
117 | // ob_start(); |
||
118 | // try { |
||
119 | // include $this->template; |
||
120 | // } catch (\Exception $e) { |
||
121 | // ob_get_flush(); |
||
122 | // throw $e; |
||
123 | // } |
||
124 | // return ob_get_clean(); |
||
125 | // } |
||
126 | // |
||
127 | // /** |
||
128 | // * A utility function to strip the text of all HTML code. This function |
||
129 | // * removes all HTML tags instead of escaping them. |
||
130 | // * |
||
131 | // * @param string $text |
||
132 | // * @return string |
||
133 | // */ |
||
134 | // public function strip($text) { |
||
135 | // return php\Janitor::cleanHtml($text, true); |
||
136 | // } |
||
137 | // |
||
138 | // /** |
||
139 | // * A utility function to cut long pieces of text into meaningful short |
||
140 | // * chunks. The function is very good in cases where you want to show just |
||
141 | // * a short preview snippet of a long text. The function cuts the long string |
||
142 | // * without cutting through words and appends some sort of ellipsis |
||
143 | // * terminator to the text. |
||
144 | // * |
||
145 | // * @param string $text The text to be truncated. |
||
146 | // * @param string $length The maximum lenght of the truncated string. Might |
||
147 | // * return a shorter string if the lenght ends in the middle of a word. |
||
148 | // * @param string $terminator The ellipsis terminator to use for the text. |
||
149 | // * @return string |
||
150 | // */ |
||
151 | // public function truncate($text, $length, $terminator = ' ...') { |
||
152 | // while (mb_substr($text, $length, 1) != ' ' && $length > 0) { |
||
153 | // $length--; |
||
154 | // } |
||
155 | // return mb_substr($text, 0, $length) . $terminator; |
||
156 | // } |
||
157 | // |
||
158 | // protected function generateFromString($string, $data) { |
||
159 | // \ntentan\utils\StringStream::register(); |
||
160 | // file_put_contents('string://template', $string); |
||
161 | // $this->template = 'string://template'; |
||
162 | // return $this->generate($data); |
||
163 | // } |
||
164 | // |
||
165 | // public function __destruct() { |
||
166 | // \ntentan\utils\StringStream::unregister(); |
||
167 | // } |
||
168 | |||
169 | } |
||
170 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.