https://github.com/millironx/kelpie.jl
:dog2: I accidentally built an HTML templating engine in Julia
https://github.com/millironx/kelpie.jl
html julia template-engine
Last synced: 4 months ago
JSON representation
:dog2: I accidentally built an HTML templating engine in Julia
- Host: GitHub
- URL: https://github.com/millironx/kelpie.jl
- Owner: MillironX
- License: mit
- Created: 2022-03-31T23:26:31.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-04-06T19:34:41.000Z (about 4 years ago)
- Last Synced: 2025-12-08T20:51:57.717Z (7 months ago)
- Topics: html, julia, template-engine
- Language: Julia
- Homepage:
- Size: 201 KB
- Stars: 11
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Citation: CITATION.bib
Awesome Lists containing this project
README
# Kelpie
[](https://MillironX.github.io/Kelpie.jl/stable)
[](https://MillironX.github.io/Kelpie.jl/dev)
[](https://github.com/MillironX/Kelpie.jl/actions/workflows/CI.yml?query=branch%3Amaster)
[](https://codecov.io/gh/MillironX/Kelpie.jl)
[](https://github.com/invenia/BlueStyle)
[](https://JuliaCI.github.io/NanosoldierReports/pkgeval_badges/report.html)
[](https://pkgs.genieframework.com?packages=Kelpie)
:dog2: I accidentally built an HTML templating engine in Julia. It looked a lot
like [Pug](https://pugjs.org), 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:
```julia
add Kelpie
```
## Usage
Most HTML elements[^1] 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](https://github.com/JuliaIO/EzXML.jl) Document or
Node.
```julia
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
```html
Kelpie.jl is awesome!
Dogs are cool
Julia is cool
Kelpies make great herding dogs for cows.
Kelpies make great herding dogs for sheep.
Kelpies make great herding dogs for chickens.
```
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 `
`s, you need to use `html_div`.
[julia repl]: https://docs.julialang.org/en/v1/manual/getting-started/
[pkg mode]: https://docs.julialang.org/en/v1/stdlib/Pkg/