import html_dsl
const page = html:
heads:
title "Title"
meta(name="foo", content="bar")
bodys:
p "Powered by Nim Metaprogramming"
`<!--` "HTML Comment"
a(text="Nim", href="https://nim-lang.org")
divs:
p "Example"
assert page is string
echo page
Build for Development:
<!DOCTYPE html>
<html class='has-navbar-fixed-top'>
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="foo" content="bar" >
<title>Title</title>
</head>
<body class='has-navbar-fixed-top'>
<p > Powered by Nim Metaprogramming</p>
<!-- HTML Comment -->
<a href="https://nim-lang.org" > Nim</a>
<div >
<p > Example</p>
<p > Example</p>
</div>
</body>
</html>
Build for Release:
<!DOCTYPE html><html class='has-navbar-fixed-top'><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="foo" content="bar" ><title>Title</title></head><body class='has-navbar-fixed-top'><p>Powered by Nim Metaprogramming</p><a href="https://nim-lang.org" >Nim</a><div><p>Example</p><p>Example</p></div></body></html>
const
, 42
Kilobytes Hello World file size.func
.<div>
is named divs
, <body>
is named bodys
, <head>
is named heads
, to avoid eventual name shadowing with other libs.Yes.