Skip to content
This repository has been archived by the owner on Nov 20, 2022. It is now read-only.

Convert HTML to an array so the Builder can parse it #3

Open
3 tasks
Fleuv opened this issue Aug 27, 2020 · 0 comments
Open
3 tasks

Convert HTML to an array so the Builder can parse it #3

Fleuv opened this issue Aug 27, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@Fleuv
Copy link
Contributor

Fleuv commented Aug 27, 2020

Is your feature request related to a problem? Please describe.
The readability of an array can already become very bad after supplying an array for a component with 2 or more nested children.

Describe the solution you'd like
This can be improved by using a similar approach as React did with the invention of their JSX syntax. Except this time without the use of JavaScript, but instead with PHP.

Acceptance Criteria

  • HTML element tags are converted to Element tags.
  • HTML Attributes are converted to Element props.
  • HTML Children are converted to Element children.

Test case

A HTML parser might accept a string like this:

<article>
  <h1 align="center">Hello World</h1>
  <p>foo bar...</p>
</article>

Which can be converted into an array like this:

[
    [
        'tag' => 'article',
        'children' => [
            [
                'tag' => 'h1',
                'props' => ['align'=>'center'],
                'children' => 'Hello World'
            ],
            [
                'tag' => 'p',
                'children' => 'foo bar...',
            ],
        ],
    ],
];
@Fleuv Fleuv added the enhancement New feature or request label Aug 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant