WebReflection / uland

A µhtml take at neverland
ISC License
108 stars 2 forks source link

Html content #1

Closed alexey13 closed 4 years ago

alexey13 commented 4 years ago

Good day, Andrea! It's not working for uland ${{html: htmlContent}} ? https://codepen.io/alexzhav/pen/RwrZPPw

WebReflection commented 4 years ago

no, but this works everywhere:

render(document.body, html([htmlContent]));
WebReflection commented 4 years ago

if you have repeated use cases, use a Map to avoid re-parsing each time the same html blob.

const fakeplates = new Map;
const setplate = html => {
  const fakeplate = [html];
  fakeplates.set(html, fakeplate);
  return fakeplate;
};

render(document.body, html(
  fakeplates.get(htmlContent) || setplate(htmlContent)
));
WebReflection commented 4 years ago

if you have static strings with interpolated values and you want to use these as arguments for template literals tag functions, check tag-params out.

alexey13 commented 4 years ago

Get it, thanks a lot!