|
|
|
|
|
by _hardwaregeek
2525 days ago
|
|
I kinda don't get the whole "put html in template literals". Wouldn't there be no syntax highlighting? And the framework is either putting the string into the DOM with some regex manipulations, which would lead to some very confusing error messages, or it's parsing the string into a tree, which means it needs to implement what's essentially XML parsing, which would come with an overhead. And for what? Avoiding JSX? If you don't like JSX, just desugar it to nested function calls. Or just use a templating language. |
|
lit-html works by passing the template strings to the built-in HTML parser, so it doesn't need to bring its own.
The benefit isn't just avoiding JSX and build steps, but more importantly avoiding VDOM and expensive diffs. Template literals separate the static parts if a template from the dynamic and remove the need to diff the parts that never change. It's more efficient.