Current section
Files
Jump to
Current section
Files
lib/hat.ex
defmodule HAT do
@moduledoc """
HAT - HTML Aware Templates.
HAT is a fork of Phoenix's HEEx, focused solely on static template rendering.
## Features
* syntax checking
* `assigns` enhancement:
- `@` syntax
- declarative assigns
* component system
* protection on XSS
## Modules
The core feature is implemented by `HAT.Compiler`.
And, other additional features are implemented by following modules:
* `HAT.Sigil`
* `HAT.Slot`
* `HAT.Assigns`
* `HAT.DeclarativeAssigns`
In practice, we rarely use these modules directly. Instead, we use `use HAT`.
"""
@doc """
Quick setup for using this engine.
"""
defmacro __using__(opts \\ []) do
quote bind_quoted: [opts: opts] do
import HAT.Sigil
import HAT.Slot
import HAT.Assigns
use HAT.DeclarativeAssigns, opts
end
end
# TODO: create Combo.Template.HATEngine, and move following function to it.
def compile(path, _name) do
# We need access for the caller, so we return a call to a macro.
quote do
require HAT.Compiler
HAT.Compiler.compile_file(unquote(path))
end
end
end