Componetization syntax
Current:
<div>
<?php View::render('myComponent', [
'attr' => 'value'
] ?>
</div>
Requested🙌🏽🔥
<div>
<f-MyComponent attr="value" />
</div>
f prefix can be customizable
- components folder must be defined first or
/views/components is taken by default and map functions or classes
function MyComponent(array $props): string {
return <<<html
<div>{$props['attr']}</div>
html;
}
// or
class MyComponentClass {
function __construct(array $props) {
// initialize properties, call preparation methods or whatever
}
function render(): string {
// return html code
}
}