Lit-html: bindings in <template> not working

Created on 11 Aug 2017  路  5Comments  路  Source: Polymer/lit-html

const who = 'world';
render(html`<template id="res">hello ${who}</template>`, document.body);

// `hello {{}}` instead of `hello world` :(
console.log(document.getElementById('res').innerHTML);
Medium Bug

Most helpful comment

Well, with #50 I think we can do this, but it might be a bit confusing to deal with two separate data-binding systems. The lit-html bindings are going to change the <template>'s content. You have that right above, but I wonder how many would get that distinction immediately.

It's be nice to have an iron-list that took something even a bit more abstract than template elements, maybe a function that produces DOM (something like (item, index) => Node).

All 5 comments

Oh, interesting...

I suppose we have to walk into nested template contents when preparing a template.

@valdrinkoshi #50 starts us on the path to being able to fix this. Because it does a recursive walk on the template, rather than using a TreeWalker, we can choose to special-case