ginger

{{ “HTML Templates For Humans” }}

https://ginger.tobiasdammers.nl/

https://github.com/tdammers/ginger/

https://hackage.haskell.org/package/ginger

tdammers@gmail.com

irc.freenode.org - tdammers

What

Jinja2 HTML templating for Haskell.

<h1>{{ title }}</h1>
<div>{{ intro|markdown }}</div>
{% for page in pages %}
  <div class="page">
    <h3><a href="{{ page.url }}">{{ page.title }}</a></h3>
    {% if page.image %}
      <img class="page-image"
        src="/images/{{ page.image|urlencode }}"/>
    {% endif %}
    {{ page.intro|markdown|str|ellipse(200) }}
  </div>
{% endfor %}

Key Features

  • Interpret templates at runtime → fast dev cycles, no recompiling, no Haskell toolchain needed

  • Familiar syntax → no need to learn yet another template language

  • Complete expression language → logic does belong in templates, as long as it’s display logic

  • Fully sandboxable → host application determines what templates can do; use type system to enforce

  • Automatic HTML-encoding → secure defaults, bye-bye XSS; type system to the rescue

  • DOM-agnostic → flexibility first

What To Work On

  • Improve Jinja2 compatibility / feature parity. E.g.:
    • is (tests)
    • missing builtins
    • {% filter %}
  • Performance improvements
  • Compiling
    • to Haskell Q (for QQ / TH)
    • to other languages (PHP? JS?)

Full list: https://github.com/tdammers/ginger/issues

More! More! More!

Ginger Website: https://ginger.tobiasdammers.nl/

Hackage: https://hackage.haskell.org/package/ginger

GitHub: https://github.com/tdammers/ginger/

Jinja2: http://jinja.pocoo.org/

Twig: https://twig.symfony.com/

This slideshow: https://ginger.tobiasdammers.nl/zurihac