Packages

Phoenix template engine for pandoc: templates in any format pandoc reads, with EEx tags, converted to HTML at compile time. Installs a pinned, verified pandoc release.

Current section

Files

Jump to
Raw

README.md

# Phoenix Template Engine for Pandoc

A Phoenix template engine that uses [pandoc][0] to convert templates to HTML.
It fully supports EEx tags as well as all input formats supported by pandoc.
Pandoc runs at compile time; EEx tags are evaluated afterwards, so they output
HTML.

## Installation

A pinned [pandoc][1] release is downloaded and verified on first use; see
`PhoenixPandoc.Installer` to pin another release or use an installed pandoc.

The package can be installed by adding `phoenix_pandoc` to the list of dependencies in your `mix.exs`:

```elixir
defp deps do
  [
    {:phoenix_pandoc, "~> 2.0"},
  ]
end
```

## Configuration

To use this template engine with Phoenix, you have to configure it for each
file extension you want to use. Add lines to your `config.exs` similar to:

```elixir
config :phoenix, :template_engines,
  md: PhoenixPandoc.Engine,
  rst: PhoenixPandoc.Engine
```

To enable live reloading for those extensions, you need to edit the patterns
that `phoenix_live_reload` watches. For the above example, your
`config/dev.exs` might look like:

```elixir
config :my_app, MyAppWeb.Endpoint,
  live_reload: [
    patterns: [
      ~r"priv/static/(?!uploads/).*(js|css|png|jpeg|jpg|gif|svg)$",
      ~r"lib/my_app_web/(controllers|live|components)/.*(ex|heex|md|rst)$"
    ]
  ]
```

### Optional Markdown Configuration

Pandoc supports a number of markdown flavors. See the `PhoenixPandoc` module
for details on how to configure the default flavor.

[0]: https://github.com/jgm/pandoc
[1]: https://pandoc.org/installing.html