FrancisTemplate.Markdown (Francis Template v0.2.0)

View Source

Markdown template engine backed by MDEx.

Add MDEx alongside francis_template in the host application because it is an optional dependency:

def deps do
  [
    {:francis_template, "~> 0.2"},
    {:mdex, "~> 0.13.5"}
  ]
end

.md files are registered automatically. Markdown is rendered to HTML and can be wrapped in any FrancisTemplate layout:

render(conn, "article.md", [title: "Field notes"],
  layout: "layout.html.eex"
)

Markdown itself does not interpolate assigns. Assigns are forwarded to MDEx as its :assigns option so MDEx plugins and pipelines can use them, and they remain available to the FrancisTemplate layout.

Configuration and safety

Configure MDEx extensions and rendering directly:

config :francis_template,
  markdown: [
    extension: [table: true, strikethrough: true]
  ]

Options are passed to MDEx.to_html!/2. MDEx omits raw HTML by default. Keep that default for untrusted Markdown. If trusted templates need raw HTML, opt in explicitly with render: [unsafe: true]; for untrusted input, use MDEx's sanitization support instead.