BSD-3-Clause licensed by Justus Adam
Maintained by [email protected]
This version can be pinned in stack with:mustache-2.3.1@sha256:0bf313b77f056eea1d2fe7c9b32312304f5de434bb0bf6fe67f39422fc0607c8,3221

mustache Travis Status Hackage Join the chat at https://gitter.im/JustusAdam/mustache

Haskell implementation of mustache templates.

Implements the official specs version 1.1.3

Motivation

The old Haskell implementation of mustache templates hastache seemed pretty abandoned to me. This implementation aims to be much easier to use and (fingers crossed) better maintained.

Since it is so easy to use and requires but a few files of code, I’ve also written a small executable that compiles and renders mustache templates with data input from json or yaml files.

Usage

Library

Please refer to the documentation on hackage.

Executable haskell-mustache

$ haskell-mustache --help
Simple mustache template substitution

arguments [OPTIONS] TEMPLATE [DATA-FILES]

Common flags:
  -t --templatedirs[=DIRECTORY]  The directory in which to search for the
                                 templates
  -? --help                      Display help message
  -V --version                   Print version information

Current implementation substitutes the TEMPLATE once with each DATA-FILE

Example

$ haskell-mustache my-template-file data-file-1.json data-file-2.json data-file-3.json

Roadmap

  • [x] String parser for mustache templates
  • [x] Template substitution
  • [x] Standalone executable
  • [x] Support for ‘set delimiter’
  • [x] More efficiency using Text rather than String
  • [x] More efficient Text parsing
  • [x] Test coverage provided via the official specs
  • [x] Haddock documentation
  • [ ] More instances for ToMustache typeclass

Changes

Mustache library changelog

v2.3.0

  • Changed EitherT to ExceptT (deprecation)
  • removed getFile from public API

v2.2.3

  • Quick fix to prevent catchSubstitute from reporting substitutions to the renderer.

v2.2.2

  • Added a function to catch a substitution result

v2.2.1

  • Quickfix for an issue with resolving in context

v2.2

  • changed substitution into a new monad
    • easier usage in lambdas and lambdas can now do nested substitution

v2.1.4

  • Treat Null as falsy in sections

v2.1.3

  • Added excaping for the apostrophe “’” as per xml spec, courtesy to @tfausak

v2.1.2

  • Fixed template cache again, as the spec requires access to the previous cache in partials as well

v2.1.1

  • Fixed an error where the substitution of partials would not use the template cache of the new partial

v2.1

  • Added API preserving checked substitution with ‘checkedSubstitute’ and ‘checkedSubstituteValue’
  • Better and more ToMustache instances. No longer are all sequences of characters serialised as strings

v2.0

  • Added QuasiQuotes and template Haskell functions for compile time template embedding.

v1.0

  • Stabilised API’s

v0.5.1.0rc-7

  • Removed dependency tagsoup
  • Added ToMustache instances for some numbers

v0.5.0.0rc-6

  • Removed any dependency on ghc 7.10-type OverlappingInstances
  • Resolved String/List overlapping instances

v0.4.0.1rc-5

  • Added a necessary OVERLAPPABLE pragma

v0.4.0.0rc-4 (current stable version)

  • Removed conversion and conversion-text dependency.
  • Subsequently removed any dependency on overlapping instances
  • Readded support for ghc version 7.8
  • Removed Char -> Value instance of ToMustache (because of overlap)
  • Renamed AST

v0.3.1.0rc-3

  • Added infix precedence to conversion operators
  • Added INLINEABLE pragma to conversion functions

v0.3.0.1rc-2

Dropped GHC 7.8 support in favor of efficient and easy data conversion.

v0.3.0.0rc-1

  • improved documentation
  • fixed a bug with scope
  • small interface changes