Home

Awesome

Nim-HTML-DSL

HTML DSL

Use

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
<details> <summary>Click to see Output</summary>

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>
</details>

Design

FAQ

  1. Zero. None. Everything is done at Compile-Time.

Yes.