Reach-like user interface tweet-library
And this is faster then React itself!
by Anton Medvedev
JavaScript
function html(a, ...vs) {
const sub = v => Array.isArray(v) ? v.join('') : v;
return a.reduce((p, c, i) => p + sub(vs[i - 1]) + c);
}
let state = {
todos: [
{title: 'one', complete: true},
{title: 'two', complete: false},
{title: 'three', complete: false},
]
};
document.body.innerHTML = html`
<ol>
${state.todos.map(todo => `
<li>
${todo.complete ? `<s>${todo.title}</s>` : todo.title}
</li>
`)}
</ol>
`;