lit-vue icon indicating copy to clipboard operation
lit-vue copied to clipboard

Support functional templates

Open egoist opened this issue 6 years ago • 2 comments

Current way:

const template = html`<div>{{ message }}</div>`

New syntax:

const template = vm => html`<div>${vm.message}</div>`
  • [ ] interpolations, like <span>${vm.message}</span>
  • [ ] prop values, like @click=${vm.inc}
  • [ ] v-for, impossible, we can convert .map to v-for but that's JSX not Vue template..
  • [ ] v-if v-else v-else-if, like <div v-if=${vm.foo}></div>

egoist avatar Jan 05 '19 16:01 egoist

Hi! What does it mean "functional templates" in current issue context? It's "Vue functional components (with FunctionalRenderContext)" or "Local inline template for current Vue component" ?

If it's the second variant - can be possible using something like this with TypeScript?

const template = (vm: Hello) => html`<div>${vm.message}</div>`

@Component
export default class Hello extends Vue {
  message: string = 'Hello, world!';
  render() {
    return template(this);
  }
}

c01nd01r avatar Jan 08 '19 20:01 c01nd01r

@c01nd01r the second one, but that doesn't work for now, html`<div>{{ message }}</div>` returns undefined. I got an idea on how to implement this, but probably as 2.0

egoist avatar Jan 09 '19 12:01 egoist