Skip to content

Latest commit

 

History

History
72 lines (58 loc) · 1.23 KB

README.md

File metadata and controls

72 lines (58 loc) · 1.23 KB

HTnoML

HTML-like DSL that that can be converted into HTML.

Test

HTnoML syntax

{:html
  {:head
    {:meta charset[utf-8]}
    {:title > This is a HTML5 template}
    {:meta name[description] content[This is a HTML5 template]}
    {:meta name[author] content[Radu Lucut]}
    {:link rel[stylesheet] href[css/style.css]}
  }
  {:body
    {class[container main] > This is HTnoML syntax}
  }
}

HTML equivalent:

<html>
  <head>
    <meta charset="utf-8" />
    <title>This is a HTML5 template</title>
    <meta name="description" content="This is a HTML5 template" />
    <meta name="author" content="Radu Lucut" />
    <link rel="stylesheet" href="css/style.css" />
  </head>

  <body>
    <div class="container main">This is HTnoML syntax</div>
  </body>
</html>

Usage

package main

import (
	"os"

	"github.com/radulucut/htnoml"
)

func main() {
	f, err := os.Open("example.htnoml")
	if err != nil {
		panic(err)
	}
	defer f.Close()

	p, err := htnoml.NewParser(f)
	if err != nil {
		panic(err)
	}

	o, err := os.Create("example.html")
	if err != nil {
		panic(err)
	}
	defer o.Close()
	p.ToHTML(o) // Convert HTnoML to HTML
}