|
34 | 34 | * @copyright Copyright (c) 2016-2023 Jorge Patricio Castro Castillo MIT License.
|
35 | 35 | * Don't delete this comment, its part of the license.
|
36 | 36 | * Part of this code is based in the work of Laravel PHP Components.
|
37 |
| - * @version 4.12 |
| 37 | + * @version 4.13 |
38 | 38 | * @link https://github.com/EFTEC/BladeOne
|
39 | 39 | */
|
40 | 40 | class BladeOne
|
41 | 41 | {
|
42 | 42 | //<editor-fold desc="fields">
|
43 |
| - public const VERSION = '4.12'; |
| 43 | + public const VERSION = '4.13'; |
44 | 44 | /** @var int BladeOne reads if the compiled file has changed. If it has changed,then the file is replaced. */
|
45 | 45 | public const MODE_AUTO = 0;
|
46 | 46 | /** @var int Then compiled file is always replaced. It's slow and it's useful for development. */
|
@@ -4160,6 +4160,30 @@ protected function compileChecked($expression): string
|
4160 | 4160 | {
|
4161 | 4161 | return $this->phpTag . "if$expression echo 'checked'; ?>";
|
4162 | 4162 | }
|
| 4163 | + protected function compileStyle($expression) { |
| 4164 | + return $this->phpTag . "echo 'class=\"'.\$this->runtimeStyle($expression).'\"' ?>"; |
| 4165 | + } |
| 4166 | + protected function compileClass($expression) { |
| 4167 | + return $this->phpTag . "echo 'class=\"'.\$this->runtimeStyle($expression).'\"'; ?>"; |
| 4168 | + } |
| 4169 | + protected function runtimeStyle($expression=null,$separator=' '): string |
| 4170 | + { |
| 4171 | + if($expression===null) { |
| 4172 | + return ''; |
| 4173 | + } |
| 4174 | + if(!is_array($expression)) { |
| 4175 | + $expression=[$expression]; |
| 4176 | + } |
| 4177 | + $result=''; |
| 4178 | + foreach($expression as $k=>$v) { |
| 4179 | + if(is_numeric($k)) { |
| 4180 | + $result.=$v.$separator; |
| 4181 | + } elseif($v) { |
| 4182 | + $result.=$k.$separator; |
| 4183 | + } |
| 4184 | + } |
| 4185 | + return trim($result); |
| 4186 | + } |
4163 | 4187 |
|
4164 | 4188 | /**
|
4165 | 4189 | * Compile the selected statements into valid PHP.
|
@@ -4195,7 +4219,7 @@ protected function compileReadonly($expression): string
|
4195 | 4219 | {
|
4196 | 4220 | return $this->phpTag . "if$expression echo 'readonly'; ?>";
|
4197 | 4221 | }
|
4198 |
| - |
| 4222 | + |
4199 | 4223 | /**
|
4200 | 4224 | * Compile the required statements into valid PHP.
|
4201 | 4225 | *
|
|
0 commit comments