Syntax: Compatibility with Pug
Expug retains most of Pug/Jade’s features, adds some Elixir’isms, and drops the features that don’t make sense.
Added
- Multiline attributes are supported. As long as you use balanced braces, Expug is smart enough to know when to count the next line as part of an expression.
button.btn(
role='btn'
class=(
get_classname(@button)
)
)= get_text "Submit"
- Multiline codeb blocks are also supported. See code for rules on how this works.
= render(
App.MyView,
"index.html",
conn: @conn)
Changed
Comments are done using
-#
as well as-//
, following Elixir conventions. The old-//
syntax is supported for increased compatibility with text editor syntax highlighting.Text attributes need to have double-quoted strings (
"
). Single-line strings will translate to Elixir char lists, which is likely not what you want.Statements with blocks like
= if .. do
…- end
should start with=
, and end in-
. This is the same as you would do in EEx.
Removed
The following features are not available due to the limitations of EEx.
- include (partials)
- block/extends (layouts & template inheritance)
- mixins (functions)
The following syntactic sugars, are not implemented, simply because they’re not idiomatic Elixir. There are other ways to accomplish them.
The following are still unimplemented, but may be in the future.
- filters
- interpolation
- multi-line statements (
-\n ...
)
The following are unimplemented, just because I don’t want to implement them.
- Doctype shorthands are limited to only
html
andxml
. The XHTML shorthands were not implemented to discourage their use.
The same
- Indent sensitivity rules of Pug/Jade have been preserved. This means you can do:
html
head
title This is indented with 4 spaces