Hasty Briefsbeta

Bilingual

What should a native DOM templating API look like?

10 months ago
  • #JavaScript
  • #Templating
  • #DOM
  • Proposal for a declarative JavaScript templating API for DOM manipulation.
  • Focus on JavaScript APIs that resemble output, similar to JSX and lit-html.
  • Constraints include web compatibility, standard file types, and no performance regressions.
  • Requirements include ergonomic API, JavaScript for control flow, and support for full HTML syntax.
  • Opinions favor functional-style programming, HTML template cloning, and support for multiple reactivity models.
  • Tagged template literals proposed as container syntax for templates, with benefits like security and performance.
  • Discussion on differentiating attributes, properties, and events in templates.
  • Composition, conditionals, and looping to be handled via JavaScript, leveraging template re-rendering and fine-grained reactivity.
  • Comparison with JSX and HTML-based templates, advocating for a JavaScript API approach.
  • Proposal aligns with existing libraries like lit-html due to shared constraints and goals.