Expug
Indented shorthand HTML templates for Elixir
Expug is a template language based on Pug (formerly known as Jade). This is a work-in-progress.
Installation
Add expug to your list of dependencies in mix.exs
:
def deps do
[{:expug, "~> 0.1.1"}]
end
Also see phoenix_expug for Phoenix integration.
The language
Expug lets you write HTML as indented shorthand, inspired by Haml, Slim, Pug/Jade, and so on.
doctype html
html
meta(charset="utf-8")
title Hello, world!
body
a(href=@link)
| This is a link
Also see:
- Comparison with Pug
- Jade language reference (jade-lang.com)
Prior art
There’s calliope and slime that brings Haml and Slim to Elixir, respectively. Expug offers a bit more:
- Jade syntax! - something I personally find more sensible than Slim.
- True multilines - Expug has a non-line-based tokenizer that can figure out multiline breaks.
- Correct line number errors - Errors in Expug will always map to the correct source line numbers.
How it works
Expug converts a .pug
template into an EEx string:
iex> Expug.to_eex!(~s[div(role="alert")= @message])
"<div role=<%= raw(\"alert\") %>><%= @message %>"
See the module Expug
for details.
To use Expug with Phoenix, see phoenix_expug.
Thanks
expug © 2016+, Rico Sta. Cruz. Released under the MIT License.
Authored and maintained by Rico Sta. Cruz with help from contributors (list).
ricostacruz.com · GitHub @rstacruz · Twitter @rstacruz