-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<!DOCTYPE html> broke render #130
Comments
@Akiyamka I’m not sure, but I think htm is specially targeted to JSX (with some HTML extensions), so it’s not surprising that htm doesn’t support You shouldn’t be doing that anyway, I can’t think of any use case of using htm for a total HTML document. Most likely you should already have the |
I often develop cli tools that come with a minimal form page (optional). http.createServer(function(request, response) {
response.writeHeader(200, {"Content-Type": "text/html"});
response.write(html`
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
</head>
<body>
<form action="/upload" method="post" enctype="multipart/form-data">
<div class="form">
${
Object.entries(config).map(([key, val]) => {
return html`<div>
<label for=${key}>${humanReadable(key)}</label>
<input id=${key} type=${getType(val)} name=${key} value=${val} required />
</div>`
})
}
<input type="submit" value="Run!" />
</div>
</form>
</body>
</html>
` );
response.end();
}).listen(8000); |
@Akiyamka duplicate/related #91
Personally I 100% agree that In order to make your case work, just close doctype: |
That solution does not work. I found that the only way to get a full html page is to make a template that has one root element in the body and use render to target it's id. |
HTM is intentionally not a full HTML parser. It can handle arbitrary Element and Comment nodes, but does not support other tag types like Doctype or Processing Instruction. For this specific case, I'd recommend prepending the doctype as a string: http.createServer(function(request, response) {
response.writeHeader(200, {"Content-Type": "text/html"});
response.write('<!DOCTYPE html>' + html`
<html lang="en" >
<head>
<title>etc</title>
</head>
<body>
etc
</body>
</html>
` );
response.end();
}).listen(8000); |
HTM is a very cool library, thanks a lot to everyone who took part in the development, I really love it!
I found one whole curious bug the reason of which I do not yet understand.
the following code will produce incorrect output:
Nothing special, just emmet generated boilerplate ( ! + tab ).
(this tool is actively used in front-end development and is built into some IDE by default)
Output of this code:
Interactive repl
Any ideas how to fix this?
The text was updated successfully, but these errors were encountered: