🐕 I accidentally built an HTML templating engine in Julia
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Go to file
Thomas A. Christensen II 438e87617c
Update code to use Prettier style
Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com>
2 years ago
.github Update code to use Prettier style 2 years ago
.vscode Update code to use Prettier style 2 years ago
docs Update code to use Prettier style 2 years ago
src Add function for divs 2 years ago
test Add doctests as unit tests 2 years ago
.JuliaFormatter.toml Add .JuliaFormatter.toml 2 years ago
.gitignore Files generated by PkgTemplates 2 years ago
.markdownlint.yml Add markdownlint config file 2 years ago
CHANGELOG.md Add a changelog 2 years ago
CITATION.bib Files generated by PkgTemplates 2 years ago
CODE_OF_CONDUCT.md Add CODE_OF_CONDUCT 2 years ago
CONTRIBUTING.md Add contributing guidelines 2 years ago
LICENSE Files generated by PkgTemplates 2 years ago
Project.toml Add EzXML to test deps 2 years ago
README.md Update code to use Prettier style 2 years ago
cspell.json Update code to use Prettier style 2 years ago

README.md

Kelpie

Stable Dev Build Status Coverage Code Style: Blue PkgEval Genie Downloads

🐕 I accidentally built an HTML templating engine in Julia. It looked a lot like Pug, but I like working dogs better, so I named it Kelpie.

Installation

You can install straight from the Julia REPL. Press ] to enter pkg mode, then:

add Kelpie

Usage

Most HTML elements1 now have functions of the same name: simply pass the contents as a positional argument, and attributes as keyword arguments, and everything will be returned as an EzXML Document or Node.

import EzXML: prettyprint

doc = html([
  head([
    title("Kelpie.jl is awesome!"),
  ]),
  body([
    header([
      h1("Dogs are cool"),
      h2("Julia is cool"),
    ]),
    main([
      img(;
        src="/kelpie-on-sheep-back.jpg",
        alt="A Kelpie herding sheep"
      ),
      [
        p("Kelpies make great herding dogs for $animal.")
        for animal in ["cows", "sheep", "chickens"]
      ]...,
    ]),
  ]),
])

prettyprint(doc)

Turns into

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<head>
  <title>Kelpie.jl is awesome!</title>
</head>
<body>
  <header>
    <h1>Dogs are cool</h1>
    <h2>Julia is cool</h2>
  </header>
  <main>
    <img src="/kelpie-on-sheep-back.jpg" alt="A Kelpie herding sheep" />
    <p>Kelpies make great herding dogs for cows.</p>
    <p>Kelpies make great herding dogs for sheep.</p>
    <p>Kelpies make great herding dogs for chickens.</p>
  </main>
</body>

Everything is pure Julia, so your imagination is the limit!


  1. Exception: div is the division function, and I wanted to leave it that way. To make <div>s, you need to use html_div. ↩︎