stache: Mustache templates for Haskell

[ bsd3, library, program, text ] [ Propose Tags ] [ Report a vulnerability ]

Mustache templates for Haskell.


[Skip to Readme]

Flags

Manual Flags

NameDescriptionDefault
dev

Turn on development settings.

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5, 0.1.6, 0.1.7, 0.1.8, 0.2.0, 0.2.1, 0.2.2, 1.0.0, 1.1.0, 1.1.1, 1.1.2, 1.2.0, 1.2.1, 2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.2.0, 2.2.1, 2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.4.0
Change log CHANGELOG.md
Dependencies aeson (>=2 && <3), base (>=4.15 && <5), containers (>=0.5 && <0.9), deepseq (>=1.4 && <1.6), directory (>=1.2 && <1.4), filepath (>=1.2 && <1.6), gitrev (>=1.3 && <1.4), megaparsec (>=7 && <10), mtl (>=2.1 && <3), optparse-applicative (>=0.14 && <0.20), stache, template-haskell (>=2.11 && <2.25), text (>=1.2 && <2.2), vector (>=0.11 && <0.14), yaml (>=0.8 && <0.12) [details]
Tested with ghc ==9.10.3, ghc ==9.12.4, ghc ==9.14.1
License BSD-3-Clause
Author Mark Karpov <markkarpov92@gmail.com>
Maintainer Mark Karpov <markkarpov92@gmail.com>
Uploaded by mrkkrp at 2026-06-17T19:51:45Z
Category Text
Home page https://github.com/mrkkrp/stache
Bug tracker https://github.com/mrkkrp/stache/issues
Source repo head: git clone https://github.com/mrkkrp/stache.git
Distributions LTSHaskell:2.3.4, Stackage:2.3.4
Reverse Dependencies 7 direct, 0 indirect [details]
Executables stache
Downloads 21882 total (43 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for stache-2.4.0

[back to package description]

Stache

Hackage Stackage Nightly Stackage LTS CI

This is a Haskell implementation of Mustache templates. The implementation conforms to the version 1.1.3 of the official Mustache specification. It has a minimal but complete API—three functions to compile templates (from directory, from file, and from lazy text) and one to render them.

The implementation uses the Megaparsec parsing library to parse the templates which results in high-quality error messages.

For rendering one only needs to create Aeson's Value that is used for interpolation of template variables. Since the library re-uses Aeson's instances and most data types in the Haskell ecosystem are instances of classes like Data.Aeson.ToJSON, the process is simple for the end user.

Template Haskell helpers for compilation of templates at compile time are available in the Text.Mustache.Compile.TH module.

One feature that is not currently supported is lambdas. The feature is marked as optional in the spec and can be emulated via processing of parsed template representation. The decision to drop lambdas is intentional, for the sake of simplicity and better integration with Aeson.

Usage

Here is an example of basic usage:

{-# LANGUAGE OverloadedStrings #-}

module Main (main) where

import Data.Aeson
import Data.Text
import Text.Megaparsec
import Text.Mustache
import qualified Data.Text.Lazy.IO as TIO

main :: IO ()
main = do
  let res = compileMustacheText "foo"
        "Hi, {{name}}! You have:\n{{#things}}\n  * {{.}}\n{{/things}}\n"
  case res of
    Left bundle -> putStrLn (errorBundlePretty bundle)
    Right template -> TIO.putStr $ renderMustache template $ object
      [ "name"   .= ("John" :: Text)
      , "things" .= ["pen" :: Text, "candle", "egg"]
      ]

If I run the program, it prints the following:

Hi, John! You have:
  * pen
  * candle
  * egg

For more information about Mustache templates the following links may be helpful:

License

Copyright © 2016–present Mark Karpov

Distributed under BSD 3 clause license.