mecha-cms / mecha

Minimalist content management system.

Home Page:https://mecha-cms.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nested HTML Content

taufik-nurrohman opened this issue · comments

Having HTML class to accept array as the content gives us possibilities to serialize the markup even further. Here are some examples that I hope I can implement:

< 3.0.0

new HTML(['a', '<b>c</b><d>e</d>f']);
new HTML(new HTML(['a', '<b>c</b><d>e</d>f']));

>= 3.0.0

new HTML(['a', [
    '<b>c</b>',
    '<d>e<f>g</f></d>',
    'f'
]]);
new HTML(['a', [
    new HTML(['b', 'c']),
    new HTML(['d', [
        new HTML([false, 'e']),
        new HTML(['f', 'g'])
    ]]),
    new HTML([false, 'f'])
]]);
new HTML(['a', [
    ['b', 'c'],
    ['d', [
        [false, 'e'],
        ['f', 'g']
    ]],
    [false, 'f']
]]);

The only problem, I think, is about solving the reverse version:

< 3.0.0

new HTML('<a><b>c</b><d>e<f>g</g></d>f</a>'); // `['a', '<b>c</b><d>e<f>g</g></d>f', []]`

>= 3.0.0

new HTML('<a><b>c</b><d>e<f>g</g></d>f</a>'); // `['a', [['b', 'c'], ['d', [[false, 'e'], ['f', 'g']]], [false, 'f']], []]`