Html var into html
See original GitHub issueHi,
First I’ve updated my code with the 5.0.4 api version. Very good work!
Expected behavior
I want to include in my template string a HTML string from a var.
Actual behavior
The html output is a string so by example my img tag is literally outputted as string and no image is shown.
"coucou <img class="emojione" alt="🙂" src="//cdn.jsdelivr.net/emojione/assets/png/1f642.png?v=2.1.2"/>"
Steps to reproduce behavior
Example:
import html from 'choo/html';
import emojione from 'emojione_minimal';
emojione.ascii = true;
module.exports = (input, emit) => {
return html`
<div>${emojione.shortnameToImage(input.text)}</div>
`;
};
I’ve tried with the html() function instead of html`` but bel send an error:
Uncaught DOMException: Failed to execute 'setAttribute' on 'Element': 'emojione"' is not a valid attribute name.
I’ve tried to include my emojione return value into an another var but bel send always a setAttribute error.
Thanks for your help.
Yu.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How do I use this JavaScript variable in HTML?
You don't "use" JavaScript variables in HTML. HTML is not a programming language, it's a markup language, it just "describes" what the page ......
Read more >HTML var tag
The <var> tag is used to defines a variable in programming or in a mathematical expression. The content inside is typically displayed in...
Read more ><var>: The Variable element - HTML - MDN Web Docs - Mozilla
The <var> HTML element represents the name of a variable in a mathematical expression or a programming context.
Read more >How to add a variable in HTML?
Use the <var> tag in HTML to add a variable. The HTML <var> tag is used to format text in a document. It...
Read more >How to use the var element in HTML
The <var> element in HTML defines a text as a variable and can be used to define variables of a mathematical expression or...
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 FreeTop 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
Top GitHub Comments
@yudao - I saw an error similar to yours when passing a string directly to
html()
.It worked when I passed an array of strings as the first argument, which is what tagged templates literals do.
Does this work?
@greggraf Sorry for the delay. Awesome tip ! it’s working like a charm !
Thanks all for your help!
Yu.