Git Product home page Git Product logo

nim-html-dsl's Introduction

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

Design

  • 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 named divs, <body> is named bodys, <head> is named heads, to avoid eventual name shadowing with other libs.
  • HTML5, UTF-8, Responsive, all Tags supported, all Attributes supported.

FAQ

  • Whats the Performance cost of using this?.
  1. Zero. None. Everything is done at Compile-Time.
  • Can be used with Jester?.

Yes.

nim-html-dsl's People

Contributors

0atman avatar juancarlospaco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

0atman terkwood

nim-html-dsl's Issues

Duplicated children

Disclaimer ;oP: I am starting to use Nim with web technologies (I am new to both).

When using divs, what it is underneath appears twice. As shown in the README:

    divs:
      p "Example"

produces:

<div >
  <p > Example</p>
  <p > Example</p>
</div>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.