Live data from Hacker News

Hyperscript Tagged Markup: JSX alternative using standard tagged templates

github.com

91–93 of 93 posts

Re: Hyperscript Tagged Markup: JSX alternative using standard tagged templates

#91

Earlier quoted context omitted.

No, that's incorrect. Interpolations (${}) are preserved. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Let's return to the original statement, shall we? > These are tagged templates, not strings. They work as code at runtime, and it already has support to optimize it, compile it, etc. So. How exactly do they "work as code" and "have support to optimize it, compile it, etc."? Here's HTM's main function https://github.com/developit/htm/blob/master/src/index.mjs#L... It: concatenates strings, parses (via regexes), then c…

I was responding to your false assertion that f`s` is the exact equivalent of f("s"), which only holds true without interpolations. f`a${b}c`) becomes f("a", b, "c").

Secondly, the answer is Babel. Since the string's components are part of the AST, it can optimize and compile it as the original poster claimed.

Re: Hyperscript Tagged Markup: JSX alternative using standard tagged templates

#93

Earlier quoted context omitted.

Let's return to the original statement, shall we? > These are tagged templates, not strings. They work as code at runtime, and it already has support to optimize it, compile it, etc. So. How exactly do they "work as code" and "have support to optimize it, compile it, etc."? Here's HTM's main function https://github.com/developit/htm/blob/master/src/index.mjs#L... It: concatenates strings, parses (via regexes), then c…

I was responding to your false assertion that f`s` is the exact equivalent of f("s"), which only holds true without interpolations. f`a${b}c`) becomes f("a", b, "c"). Secondly, the answer is Babel. Since the string's components are part of the AST, it can optimize and compile it as the original poster claimed.

> which only holds true without interpolations. f`a${b}c`) becomes f("a", b, "c").

The difference is so subtle as to be irrelevant. You still need to manually parse, process and assemble strings. There’s no magic. There’s no code. It’s just strings (with some values here and there).

It’s enough to see the implementation of HTM (or lit-html or any other library using tagged literals) to see that.

> the answer is Babel

Which is only mentioned once the bullshit claims about tagged literals are refuted.

Babel is not exactly the answer, but as poor man’s macros it will do.

Post reply on HN