core icon indicating copy to clipboard operation
core copied to clipboard

View class steroids πŸ™ŒπŸ½

Open fadrian06 opened this issue 10 months ago β€’ 1 comments

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
  }
}

fadrian06 avatar Apr 24 '24 07:04 fadrian06