Skip to content

HTML-like DSL that that can be converted into HTML

License

Notifications You must be signed in to change notification settings

radulucut/htnoml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
}

About

HTML-like DSL that that can be converted into HTML

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published