# `Braces.Handlebars.Phoenix.Engine`
[🔗](https://github.com/dbernheisel/braces/blob/v0.1.0/lib/braces/handlebars/phoenix/engine.ex#L2)

A `Phoenix.Template` engine for `.hbs` files. Only defined when `phoenix_template` is
installed.

    # config/config.exs
    config :phoenix_template, :template_engines, hbs: Braces.Handlebars.Phoenix.Engine

Then `embed_templates "emails/*"` in a `Phoenix.Component` module, or a Phoenix view, turns
`emails/welcome.html.hbs` into a `welcome/1` function. Its assigns are the template's data,
so `{{first_name}}` reads `@first_name`.

The file is compiled into Elixir code with your module, as `Braces.Handlebars.embed_templates/2`
compiles it, and renders as `Braces.Handlebars.render!/3` renders it. A template that doesn't
parse, or that can't render whatever its data, raises a `CompileError` at its line, with
the line and a caret under the error. The engine has no custom helpers or partials, so a
partial, or a helper that isn't built in, fails compilation too. It renders in strict mode,
as embedded templates do, so a missing value raises a `Braces.Handlebars.RenderError`.

In an HTML format, as Phoenix decides for `.eex` templates, values are escaped as
Handlebars.js escapes them, and the result is safe HTML that Phoenix doesn't escape again.
In other formats, such as `welcome.text.hbs`, values are written as they are.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
