observablehq / htl

A tagged template literal that allows safe interpolation of values into HTML, following the HTML5 spec
https://observablehq.com/@observablehq/htl
ISC License
305 stars 24 forks source link

Expose parser #3

Closed dy closed 4 years ago

dy commented 4 years ago

HTL is nice sugared alternative to htm and hyperx. Would be nice to be able to use its parser separately, for eg. VDOM purposes.

mbostock commented 4 years ago

What do you have in mind? HTL doesn’t construct an intermediate representation of the DOM that would be suitable for passing to a VDOM implementation (such as HyperScript or React.createElement). Instead, HTL concatenates markup which is then parsed by the browser using a template element.

We could expose the generated markup, but I don’t see how that would be especially useful outside of this library since it will contain the attribute and data placeholders (e.g., an attribute named “::1” or a comment “<!--::2-->”).

dy commented 4 years ago

I see. Yes, there doesn’t seem to be a simple way to convert html string with placeholders to hyperscript. Only if using htm for that purpose) I guess that can be closed then.

On Wed, Dec 11, 2019 at 12:53 PM Mike Bostock notifications@github.com wrote:

What do you have in mind? HTL doesn’t construct an intermediate representation of the DOM that would be suitable for passing to a VDOM implementation (such as HyperScript or React.createElement). Instead, HTL concatenates markup which is then parsed by the browser using a template element.

We could expose the generated markup, but I don’t see how that would be especially useful outside of this library since it will contain the attribute and data placeholders (e.g., an attribute named “::1” or a comment “”).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/observablehq/htl/issues/3?email_source=notifications&email_token=AACJII6QLPZHTETMRUW6CSLQYESIDA5CNFSM4JZRTYNKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGUAIDY#issuecomment-564659215, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACJII5FKUPNT7BRAADSOVDQYESIDANCNFSM4JZRTYNA .

mbostock commented 4 years ago

Copy that. Thanks for the suggestion regardless!