HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Modulestache-2.4.0GHC2021

Text.Mustache.Compile.TH

Template Haskell helpers to compile Mustache templates at compile time. This module is not imported as part of Text.Mustache, so you need to import it yourself. Qualified import is recommended, but not necessary.

Synopsis
  • Packagestache-2.4.0
  • Exports5
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceTH.hs
valuecompileMustacheDir
  1. :: PName

    Which template to select after compiling

  2. -> FilePath

    Directory with templates

  3. -> Q Exp

    The resulting template

Compile all templates in the specified directory and select one. Template files should have the extension mustache, (e.g. foo.mustache) to be recognized. This function does not scan the directory recursively.

This version compiles the templates at compile time.

compileMustacheDir = compileMustacheDir' isMustacheFile
valuecompileMustacheText
  1. :: PName

    How to name the template?

  2. -> Text

    The template to compile

  3. -> Q Exp

Compile a Mustache template from Text value. The cache will contain only this template named according to given Key.

This version compiles the template at compile time.

Compile a Mustache using a QuasiQuoter. Usage:

{-# LANGUAGE QuasiQuotes #-}
import Text.Mustache.Compile.TH (mustache)

foo :: Template
foo = [mustache|This is my inline {{ template }}.|]

Name of created partial is set to "quasi-quoted". You can extend cache of Template created this way using (Data.Semigroup.<>) and so work with partials as usual.