Skip to content

Write your HTML in KDL, with markdown, variable interpolation, and includes

License

Notifications You must be signed in to change notification settings

asayers/kdl2html

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Transforms KDL to HTML according to this spec. Also supports:

  • Markdown nodes
  • Include files (HTML, KDL, markdown)
  • String interpolation
  • Set variables with the CLI or with an envfile

Sample

navbar.kdl:

nav {
    a href="index.html" "Home"
    a href="about.html" "About"
}

news.md:

# News

Nothing going on!

template.kdl:

!doctype "html"
html lang="en" {
    head {
        meta charset="utf-8"
        title "${TITLE} - AwesomeSite"
        link href="/style.css" rel="stylesheet"
    }
    body {
        div class="container" {
            header {
                div class="logo" {
                    img src="logo.png"
                    span "AwesomeSite"
                }
            }
            @include "navbar.kdl"
            main {
                markdown {
                    "Welcome to AwesomeSite, the _craziest_ site"
                    "on the entire 'net since ${YEAR}!"
                }
                @include "news.md"
            }
            footer "© ${YEAR} AwesomeSite"
        }
    }
}

Comile the page like this:

$ kdl2html template.kdl --bind "TITLE=home" --bind "YEAR=1999"

Here's what comes out:

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>Home - AwesomeSite</title>
		<link href="/style.css" rel="stylesheet" />
	</head>
	<body>
		<div class="container">
			<header>
				<div class="logo">
					<img src="logo.png" />
					<span>AwesomeSite</span>
				</div>
			</header>
			<nav>
				<a href="index.html">Home</a>
				<a href="about.html">About</a>
			</nav>
			<main>
				<p>Welcome to AwesomeSite, the <em>craziest</em> site
				on the entire 'net since 1999!</p>
				<h1>News</h1>
				<p>Nothing going on!</p>
			</main>
			<footer>© 1999 AwesomeSite</footer>
		</div>
	</body>
</html>

About

Write your HTML in KDL, with markdown, variable interpolation, and includes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages