1
0
Fork 0
mirror of https://github.com/MillironX/Kelpie.jl.git synced 2024-11-13 05:03:09 +00:00
🐕 I accidentally built an HTML templating engine in Julia
Find a file
Thomas A. Christensen II 8f1ddfc940
Fix html_div not splatting its passed arguments
Fixes: 58244fcb5d ("Convert array checking to argument splatting")
Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com>
2022-04-06 09:01:51 -05:00
.github Switch to testing on latest stable instead of 1.7 2022-04-05 16:05:43 -05:00
.vscode Update code to use Prettier style 2022-04-04 17:22:25 -05:00
docs Update code to use Prettier style 2022-04-04 17:22:25 -05:00
src Fix html_div not splatting its passed arguments 2022-04-06 09:01:51 -05:00
test Add a test for underscores being turned into dashes 2022-04-05 16:41:10 -05:00
.gitignore Files generated by PkgTemplates 2022-03-31 18:24:13 -05:00
.JuliaFormatter.toml Add .JuliaFormatter.toml 2022-03-31 18:36:46 -05:00
.markdownlint.yml Update CHANGELOG 2022-04-05 16:41:13 -05:00
CHANGELOG.md Version bump to v0.2.0 2022-04-05 16:51:09 -05:00
CITATION.bib Files generated by PkgTemplates 2022-03-31 18:24:13 -05:00
CODE_OF_CONDUCT.md Add CODE_OF_CONDUCT 2022-04-04 09:10:13 -05:00
CONTRIBUTING.md Add contributing guidelines 2022-04-04 11:13:54 -05:00
cspell.json Update spelling dictionary 2022-04-04 17:30:54 -05:00
LICENSE Files generated by PkgTemplates 2022-03-31 18:24:13 -05:00
Project.toml Version bump to v0.2.0 2022-04-05 16:51:09 -05:00
README.md Update README example with html node 2022-04-05 15:43:59 -05:00

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 SYSTEM "about:legacy-compat">
<html>
  <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>
</html>

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. ↩︎