Skip to content

View class steroids 馃檶馃徑#580

Description

@fadrian06

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions