- Nim HTML DSL, Domain Specific Language for HTML embedded on Nim lang code (Not a template engine).
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
Click to see Output
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>
- 1 file, ~300 Lines of Code, as fast as
const
,42
Kilobytes Hello World file size. - Works for JavaScript and NodeJS and NimScript.
- Bulma CSS ready, Spectre CSS ready.
- Minified when build for Release, Pretty-Printed when build for Development.
- Functional Programming, no side-effects, all functions are
func
. <div>
is nameddivs
,<body>
is namedbodys
,<head>
is namedheads
, to avoid eventual name shadowing with other libs.- HTML5, UTF-8, Responsive, all Tags supported, all Attributes supported.
- Whats the Performance cost of using this?.
- Zero. None. Everything is done at Compile-Time.
- Can be used with Jester?.
Yes.