ProjectEvergreen / project-evergreen

Wiki and high level "feature" tracker for Project Evergreen
https://projectevergreen.github.io/
Apache License 2.0
11 stars 1 forks source link

Add support for external HTML partials / templates (non html-in-js) #13

Open thescientist13 opened 6 years ago

thescientist13 commented 6 years ago

So that developers can use something like

import { html, render } from 'lit-html';
import template from './foo.html'; // import our template from a file
import css from './foo.css';

class Foo extends HTMLElement {
  constructor() {
    super();

    this.root = this.attachShadow({ mode: 'closed' });
    render(this.template(), this.root);
  }

  template() {
    return html`
      <style>
        ${css}
      </style>

      ${template}  // render our import
    `;
  }
}

customElements.define('foo', Foo);

or something similar, making sure to take variable interpolation into account.

thescientist13 commented 6 years ago

maybe a combination of to-string-loader!html-loader with webpack?