Create a new tagged template string vnode factory function: Codename: hypertag
See original GitHub issueI 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:
- Created 7 years ago
- Reactions:3
- Comments:29 (26 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.@dschep Also check https://github.com/hyperapp/html.