Tram-One / tram-one

🚋 Legacy View Framework For Vanilla Javascript
http://tram-one.io/
MIT License
36 stars 8 forks source link

Fragments Support! #197

Closed JRJurman closed 2 years ago

JRJurman commented 2 years ago

Summary

This PR enables fragment support in Tram-One.

This enables partial component building without cluttering the DOM, and building components that have slots for direct children.

import { registerHtml, TramOneComponent } from '../../src/tram-one';

const html = registerHtml();

const composite: TramOneComponent = () => {
  const header = html`
    <>
      <h3>Top of Description</h3>
    </>
  `;
  const body = html`
    <>
      Some Details
    </>
  `;

  return html`
    <section>
      ${header}
      ${body}
    </section>
  `;
};

export default composite;

This component results in the following DOM:

<section>
  <h3>Top of Description</h3>
  Some Details
</section>

Checklist