-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Mustache templates for Haskell
--   
--   Mustache templates for Haskell.
--   
--   Based on stache library, which uses megaparsec. This
--   library uses parsec, thus the name: microstache.
@package microstache
@version 1.0.3

-- | Types used by the package. You don't usually need to import the
--   module, because Text.Microstache re-exports everything you may
--   need, import that module instead.
module Text.Microstache.Type

-- | Mustache template as name of “top-level” template and a collection of
--   all available templates (partials).
--   
--   Template is a Semigroup. This means that you can combine
--   Templates (and their caches) using the
--   (<>) operator, the resulting Template
--   will have the same currently selected template as the left one. Union
--   of caches is also left-biased.
data Template
Template :: PName -> Map PName [Node] -> Template

-- | Name of currently “selected” template (top-level one).
[templateActual] :: Template -> PName

-- | Collection of all templates that are available for interpolation (as
--   partials). The top-level one is also contained here and the “focus”
--   can be switched easily by modifying templateActual.
[templateCache] :: Template -> Map PName [Node]

-- | Structural element of template.
data Node

-- | Plain text contained between tags
TextBlock :: Text -> Node

-- | HTML-escaped variable
EscapedVar :: Key -> Node

-- | Unescaped variable
UnescapedVar :: Key -> Node

-- | Mustache section
Section :: Key -> [Node] -> Node

-- | Inverted section
InvertedSection :: Key -> [Node] -> Node

-- | Partial with indentation level (Nothing means it was inlined)
Partial :: PName -> Maybe Word -> Node

-- | Identifier for values to interpolate.
--   
--   The representation is the following:
--   
--   
--   
- [] — empty list means implicit iterators;
--   
- [text] — single key is a normal identifier;
--   
- [text1, text2] — multiple keys represent dotted
--   names.
--   
newtype Key
Key :: [Text] -> Key
[unKey] :: Key -> [Text]

-- | Pretty-print a key, this is helpful, for example, if you want to
--   display an error message.
showKey :: Key -> Text

-- | Identifier for partials. Note that with the OverloadedStrings
--   extension you can use just string literals to create values of this
--   type.
newtype PName
PName :: Text -> PName
[unPName] :: PName -> Text

-- | Exception that is thrown when parsing of a template has failed or
--   referenced values were not provided.
data MustacheException

-- | Template parser has failed. This contains the parse error.
MustacheParserException :: ParseError -> MustacheException

-- | A referenced value was not provided. The exception provides info about
--   partial in which the issue happened PName and name of the
--   missing key Key.

-- | Deprecated: Not thrown anymore, will be removed in the next major
--   version of microstache
MustacheRenderException :: PName -> Key -> MustacheException

displayMustacheException :: MustacheException -> String

data MustacheWarning

-- | The template contained a variable for which there was no data
--   counterpart in the current context
MustacheVariableNotFound :: Key -> MustacheWarning

-- | A complex value such as an Object or Array was directly rendered into
--   the template
MustacheDirectlyRenderedValue :: Key -> MustacheWarning

displayMustacheWarning :: MustacheWarning -> String
instance GHC.Internal.Data.Data.Data Text.Microstache.Type.Key
instance GHC.Internal.Data.Data.Data Text.Microstache.Type.Node
instance GHC.Internal.Data.Data.Data Text.Microstache.Type.PName
instance GHC.Internal.Data.Data.Data Text.Microstache.Type.Template
instance GHC.Classes.Eq Text.Microstache.Type.Key
instance GHC.Classes.Eq Text.Microstache.Type.MustacheException
instance GHC.Classes.Eq Text.Microstache.Type.MustacheWarning
instance GHC.Classes.Eq Text.Microstache.Type.Node
instance GHC.Classes.Eq Text.Microstache.Type.PName
instance GHC.Classes.Eq Text.Microstache.Type.Template
instance GHC.Internal.Exception.Type.Exception Text.Microstache.Type.MustacheException
instance GHC.Internal.Exception.Type.Exception Text.Microstache.Type.MustacheWarning
instance GHC.Internal.Generics.Generic Text.Microstache.Type.Key
instance GHC.Internal.Generics.Generic Text.Microstache.Type.MustacheException
instance GHC.Internal.Generics.Generic Text.Microstache.Type.MustacheWarning
instance GHC.Internal.Generics.Generic Text.Microstache.Type.Node
instance GHC.Internal.Generics.Generic Text.Microstache.Type.PName
instance GHC.Internal.Generics.Generic Text.Microstache.Type.Template
instance GHC.Internal.Data.String.IsString Text.Microstache.Type.PName
instance GHC.Internal.Base.Monoid Text.Microstache.Type.Key
instance Control.DeepSeq.NFData Text.Microstache.Type.Key
instance Control.DeepSeq.NFData Text.Microstache.Type.PName
instance GHC.Classes.Ord Text.Microstache.Type.Key
instance GHC.Classes.Ord Text.Microstache.Type.Node
instance GHC.Classes.Ord Text.Microstache.Type.PName
instance GHC.Classes.Ord Text.Microstache.Type.Template
instance GHC.Internal.Base.Semigroup Text.Microstache.Type.Key
instance GHC.Internal.Base.Semigroup Text.Microstache.Type.Template
instance GHC.Internal.Show.Show Text.Microstache.Type.Key
instance GHC.Internal.Show.Show Text.Microstache.Type.MustacheException
instance GHC.Internal.Show.Show Text.Microstache.Type.MustacheWarning
instance GHC.Internal.Show.Show Text.Microstache.Type.Node
instance GHC.Internal.Show.Show Text.Microstache.Type.PName
instance GHC.Internal.Show.Show Text.Microstache.Type.Template

-- | Functions for rendering Mustache templates. You don't usually need to
--   import the module, because Text.Microstache re-exports
--   everything you may need, import that module instead.
module Text.Microstache.Render

-- | Render a Mustache Template using Aeson's Value to get
--   actual values for interpolation.
renderMustache :: Template -> Value -> Text

-- | Like renderMustache but also return a list of warnings.
renderMustacheW :: Template -> Value -> ([MustacheWarning], Text)

-- | Megaparsec parser for Mustache templates. You don't usually need to
--   import the module, because Text.Microstache re-exports
--   everything you may need, import that module instead.
module Text.Microstache.Parser

-- | Parse given Mustache template.
parseMustache :: FilePath -> Text -> Either ParseError [Node]

-- | Mustache Template creation from file or a Text value.
--   You don't usually need to import the module, because
--   Text.Microstache re-exports everything you may need, import
--   that module instead.
module Text.Microstache.Compile

-- | Compile all templates in specified directory and select one. Template
--   files should have extension mustache, (e.g.
--   foo.mustache) to be recognized. This function does not
--   scan the directory recursively.
--   
--   The action can throw the same exceptions as
--   getDirectoryContents, and readFile.
compileMustacheDir :: PName -> FilePath -> IO Template

-- | Return a list of templates found in given directory. The returned
--   paths are absolute.
getMustacheFilesInDir :: FilePath -> IO [FilePath]

-- | Compile single Mustache template and select it.
--   
--   The action can throw the same exceptions as readFile.
compileMustacheFile :: FilePath -> IO Template

-- | Compile Mustache template from a lazy Text value. The cache
--   will contain only this template named according to given PName.
compileMustacheText :: PName -> Text -> Either ParseError Template

-- | This is a Haskell implementation of Mustache templates. The
--   implementation conforms to the version 1.1.3 of official Mustache
--   specification https://github.com/mustache/spec. It is extremely
--   simple and straightforward to use with minimal but complete API —
--   three functions to compile templates (from directory, from file, and
--   from lazy text) and one to render them.
--   
--   For rendering you only need to create Aeson's Value where you
--   put the data to interpolate. Since the library re-uses Aeson's
--   instances and most data types in Haskell ecosystem are instances of
--   classes like ToJSON, the whole process is very simple for the
--   end user.
--   
--   Template Haskell helpers for compilation of templates at compile time
--   are available in the Text.Microstache.Compile.TH module. The
--   helpers are currently available only for GHC 8 users though.
--   
--   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.
--   
--   Here is an example of basic usage:
--   
--   
--   {-# LANGUAGE OverloadedStrings #-}
--   
--   module Main (main) where
--   
--   import Data.Aeson
--   import Data.Text
--   import Text.Microstache
--   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 err -> print err
--       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:
--   
--   
--   
- The official Mustache site:
--   https://mustache.github.io/
--   
- The manual: https://mustache.github.io/mustache.5.html
--   
- The specification: https://github.com/mustache/spec
--   
- Stack Builders Stache tutorial:
--   https://www.stackbuilders.com/tutorials/haskell/mustache-templates/
--   
module Text.Microstache

-- | Mustache template as name of “top-level” template and a collection of
--   all available templates (partials).
--   
--   Template is a Semigroup. This means that you can combine
--   Templates (and their caches) using the
--   (<>) operator, the resulting Template
--   will have the same currently selected template as the left one. Union
--   of caches is also left-biased.
data Template
Template :: PName -> Map PName [Node] -> Template

-- | Name of currently “selected” template (top-level one).
[templateActual] :: Template -> PName

-- | Collection of all templates that are available for interpolation (as
--   partials). The top-level one is also contained here and the “focus”
--   can be switched easily by modifying templateActual.
[templateCache] :: Template -> Map PName [Node]

-- | Structural element of template.
data Node

-- | Plain text contained between tags
TextBlock :: Text -> Node

-- | HTML-escaped variable
EscapedVar :: Key -> Node

-- | Unescaped variable
UnescapedVar :: Key -> Node

-- | Mustache section
Section :: Key -> [Node] -> Node

-- | Inverted section
InvertedSection :: Key -> [Node] -> Node

-- | Partial with indentation level (Nothing means it was inlined)
Partial :: PName -> Maybe Word -> Node

-- | Identifier for values to interpolate.
--   
--   The representation is the following:
--   
--   
--   
- [] — empty list means implicit iterators;
--   
- [text] — single key is a normal identifier;
--   
- [text1, text2] — multiple keys represent dotted
--   names.
--   
newtype Key
Key :: [Text] -> Key
[unKey] :: Key -> [Text]

-- | Identifier for partials. Note that with the OverloadedStrings
--   extension you can use just string literals to create values of this
--   type.
newtype PName
PName :: Text -> PName
[unPName] :: PName -> Text

-- | Exception that is thrown when parsing of a template has failed or
--   referenced values were not provided.
data MustacheException

-- | Template parser has failed. This contains the parse error.
MustacheParserException :: ParseError -> MustacheException

-- | A referenced value was not provided. The exception provides info about
--   partial in which the issue happened PName and name of the
--   missing key Key.

-- | Deprecated: Not thrown anymore, will be removed in the next major
--   version of microstache
MustacheRenderException :: PName -> Key -> MustacheException

displayMustacheException :: MustacheException -> String

data MustacheWarning

-- | The template contained a variable for which there was no data
--   counterpart in the current context
MustacheVariableNotFound :: Key -> MustacheWarning

-- | A complex value such as an Object or Array was directly rendered into
--   the template
MustacheDirectlyRenderedValue :: Key -> MustacheWarning

displayMustacheWarning :: MustacheWarning -> String

-- | Compile all templates in specified directory and select one. Template
--   files should have extension mustache, (e.g.
--   foo.mustache) to be recognized. This function does not
--   scan the directory recursively.
--   
--   The action can throw the same exceptions as
--   getDirectoryContents, and readFile.
compileMustacheDir :: PName -> FilePath -> IO Template

-- | Compile single Mustache template and select it.
--   
--   The action can throw the same exceptions as readFile.
compileMustacheFile :: FilePath -> IO Template

-- | Compile Mustache template from a lazy Text value. The cache
--   will contain only this template named according to given PName.
compileMustacheText :: PName -> Text -> Either ParseError Template

-- | Render a Mustache Template using Aeson's Value to get
--   actual values for interpolation.
renderMustache :: Template -> Value -> Text

-- | Like renderMustache but also return a list of warnings.
renderMustacheW :: Template -> Value -> ([MustacheWarning], Text)
