question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Create a new tagged template string vnode factory function: Codename: hypertag

See original GitHub issue

I think we could benefit from another hyperx-like template literal. Perhaps I should look into https://github.com/hyperapp/hyperapp/issues/88 before I do this, or maybe not, programming is fun.

1

import { html, app } from "hyperapp"

const Hello = ({ name }) => html`<h1>{name}</h1>`

app({ 
  view: model => html`
    <Hello name="world" />
  `
})

2

import { h, app } from "hyperapp"
import { html } from "hypertag"

const Hello = ({ name }) => html`<h1>{name}</h1>`

app({ 
  view: model => html`
    <Hello name="world" />
  `
})

About JSX/Hyperx and some things that I’d like to explore:

  • JSX works great and has the best support (that’s why it’s the most popular option despite “breaking” JavaScript). See: https://github.com/substack/hyperx/issues/2
  • Currently you use babel to transform JSX into vanilla JS.
  • Currently you use hyperxify to transform hyperx into vanilla JS (this involves a boilerplate that some people dislike @ngryman, but there’s no way around it unless hyperxify changes: see https://github.com/substack/hyperxify/pull/8)
  • Rolling our own tagged literal means better synergy between both projects.

Of course, if anyone wants to go ahead and work on this, just do it.

See Also:

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:29 (26 by maintainers)

github_iconTop GitHub Comments

2reactions
rbiggscommented, Apr 10, 2018

That is neat and evil, sadly. I’d be afraid to use eval in production. Would be so nice to have a Hyperx type template literal solution that didn’t require Hyperxify, it just converted to what you needed at the end automatically, sigh.

1reaction
jorgebucarancommented, Apr 11, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

Template literals (Template strings) - JavaScript | MDN
Template literals are literals delimited with backtick (`) characters, allowing for multi-line strings, string interpolation with embedded ...
Read more >
21 Using template literals and tagged templates - Exploring JS
Syntactically, a tagged template is a template literal that follows a function (or rather, an expression that evaluates to a function).
Read more >
In Javascript, if I have a very long tagged template literal, how ...
tag `This is a very long string that will be shown to ${userName}, that is annoying to have all on one line in...
Read more >
Modern JavaScript: Tagged template literals - Execute Program
Template literal strings can be "tagged" with a function. The tag function ... Then we can build new strings, or even non-string values,...
Read more >
A quick introduction to Tagged Template Literals
Tagged template literals were enabled by a new technology ... in the tag function is a variable containing an array of strings in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found