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


-- | A type-safe template engine for working with front end development tools
--   
--   Recent front end development tools and languages are growing fast and
--   have quite a complicated ecosystem. Few front end developers want to
--   be forced use Shakespeare templates. Instead, they would rather use
--   <tt>node</tt>-friendly engines such that <tt>pug</tt>, <tt>slim</tt>,
--   and <tt>haml</tt>. However, in using these template engines, we lose
--   the compile-time variable interpolation and type checking from
--   Shakespeare.
--   
--   Heterocephalus is intended for use with another feature rich template
--   engine and provides a way to interpolate server side variables into a
--   precompiled template file with <tt>forall</tt>, <tt>if</tt>, and
--   <tt>case</tt> statements.
@package heterocephalus
@version 1.0.5.7


-- | This module exports functions for working with frontend templates from
--   Haskell.
module Text.Heterocephalus

-- | A function to compile template file. This function <b>DOES NOT</b>
--   escape template variables. To render the compiled file, use
--   <tt><a>Renderer</a>.*.renderMarkup</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; putStr $ renderMarkup (let as = ["&lt;a&gt;", "b"] in $(compileTextFile "templates/sample.txt"))
--   sample
--   key: &lt;a&gt;,
--   key: b,
--   </pre>
compileTextFile :: FilePath -> Q Exp

-- | Same as <a>compileText</a> but allows the user to specify extra values
--   for template parameters. Values declared by <a>overwrite</a>
--   overwrites same name variables. Values declared by <a>setDefault</a>
--   are overwritten by same name variables.
--   
--   <pre>
--   &gt;&gt;&gt; :set -XOverloadedStrings
--   
--   &gt;&gt;&gt; :{
--   putStr $ renderMarkup (
--     let as = ["&lt;a&gt;", "b"]
--     in $(compileTextFileWith "templates/sample.txt" $ do
--       setDefault "as" [| ["foo", "bar"] |]
--     )
--   )
--   :}
--   sample
--   key: &lt;a&gt;,
--   key: b,
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; :{
--   putStr $ renderMarkup (
--     let as = ["&lt;a&gt;", "b"]
--     in $(compileTextFileWith "templates/sample.txt" $ do
--       overwrite "as" [| ["foo", "bar"] |]
--     )
--   )
--   :}
--   sample
--   key: foo,
--   key: bar,
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; :{
--   putStr $ renderMarkup (
--     let as = ["&lt;a&gt;", "b"]
--     in $(compileTextFileWith "templates/sample.txt" $ do
--       overwrite "as" [| ["bazbaz", "barbar"] |]
--       setDefault "as" [| ["foo", "bar"] |]
--       overwrite "as" [| ["baz", "foobar"] |]
--     )
--   )
--   :}
--   sample
--   key: baz,
--   key: foobar,
--   </pre>
compileTextFileWith :: FilePath -> ScopeM () -> Q Exp

-- | Same as <a>compileText</a> but allows the user to specify default
--   values for template parameters.
--   
--   <pre>
--   &gt;&gt;&gt; :set -XOverloadedStrings
--   
--   &gt;&gt;&gt; :{
--   putStr $ renderMarkup (
--     let as = ["&lt;a&gt;", "b"]
--     in $(compileTextFileWithDefault "templates/sample.txt"
--       [("as", [| ["foo", "bar"] |])]
--     )
--   )
--   :}
--   sample
--   key: &lt;a&gt;,
--   key: b,
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; :{
--   putStr $ renderMarkup (
--     $(compileTextFileWithDefault "templates/sample.txt"
--       [("as", [| ["foo", "bar"] |])]
--     )
--   )
--   :}
--   sample
--   key: foo,
--   key: bar,
--   </pre>
compileTextFileWithDefault :: FilePath -> DefaultScope -> Q Exp

-- | Same as <a>compileTextFile</a> but escapes template variables in HTML.
--   
--   <pre>
--   &gt;&gt;&gt; putStr $ renderMarkup (let as = ["&lt;a&gt;", "b"] in $(compileHtmlFile "templates/sample.txt"))
--   sample
--   key: &amp;lt;a&amp;gt;,
--   key: b,
--   </pre>
compileHtmlFile :: FilePath -> Q Exp

-- | Same as <a>compileHtmlFile</a> but allows the user to specify extra
--   values for template parameters. Values declared by <a>overwrite</a>
--   overwrites same name variables. Values declared by <a>setDefault</a>
--   are overwritten by same name variables.
--   
--   <pre>
--   &gt;&gt;&gt; :set -XOverloadedStrings
--   
--   &gt;&gt;&gt; :{
--   putStr $ renderMarkup (
--     let as = ["&lt;a&gt;", "b"]
--     in $(compileHtmlFileWith "templates/sample.txt" $ do
--       setDefault "as" [| ["foo", "bar"] |]
--     )
--   )
--   :}
--   sample
--   key: &amp;lt;a&amp;gt;,
--   key: b,
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; :{
--   putStr $ renderMarkup (
--     let as = ["&lt;a&gt;", "b"]
--     in $(compileHtmlFileWith "templates/sample.txt" $ do
--       overwrite "as" [| ["foo", "bar"] |]
--     )
--   )
--   :}
--   sample
--   key: foo,
--   key: bar,
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; :{
--   putStr $ renderMarkup (
--     let as = ["&lt;a&gt;", "b"]
--     in $(compileHtmlFileWith "templates/sample.txt" $ do
--       overwrite "as" [| ["bazbaz", "barbar"] |]
--       setDefault "as" [| ["foo", "bar"] |]
--       overwrite "as" [| ["baz", "foobar"] |]
--     )
--   )
--   :}
--   sample
--   key: baz,
--   key: foobar,
--   </pre>
compileHtmlFileWith :: FilePath -> ScopeM () -> Q Exp

-- | Same as <a>compileHtmlFile</a> but allows the user to specify default
--   values for template parameters.
--   
--   <pre>
--   &gt;&gt;&gt; :set -XOverloadedStrings
--   :{
--   putStr $ renderMarkup (
--     let as = ["&lt;a&gt;", "b"]
--     in $(compileHtmlFileWithDefault "templates/sample.txt"
--       [("as", [| ["foo", "bar"] |])]
--     )
--   )
--   :}
--   sample
--   key: &amp;lt;a&amp;gt;,
--   key: b,
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; :{
--   putStr $ renderMarkup (
--     $(compileHtmlFileWithDefault "templates/sample.txt"
--       [("as", [| ["foo", "bar"] |])]
--     )
--   )
--   :}
--   sample
--   key: foo,
--   key: bar,
--   </pre>
compileHtmlFileWithDefault :: FilePath -> DefaultScope -> Q Exp

-- | Heterocephalus quasi-quoter. This function <b>DOES NOT</b> escape
--   template variables. To render the compiled file, use
--   <tt><a>Renderer</a>.*.renderMarkup</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; renderMarkup (let as = ["&lt;a&gt;", "b"] in [compileText|sample %{ forall a &lt;- as }key: #{a}, %{ endforall }|])
--   "sample key: &lt;a&gt;, key: b, "
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; renderMarkup (let num=2 in [compileText|#{num} is %{ if even num }an even number.%{ elseif (num &gt; 100) }big.%{ else }an odd number.%{ endif }|])
--   "2 is an even number."
--   </pre>
compileText :: QuasiQuoter

-- | Heterocephalus quasi-quoter for HTML. Same as <a>compileText</a> but
--   this function does escape template variables in HTML.
--   
--   <pre>
--   &gt;&gt;&gt; renderMarkup (let as = ["&lt;a&gt;", "b"] in [compileHtml|sample %{ forall a &lt;- as }key: #{a}, %{ endforall }|])
--   "sample key: &amp;lt;a&amp;gt;, key: b, "
--   </pre>
compileHtml :: QuasiQuoter

-- | A type to handle extra scopes. This is opaque type, so use
--   <a>setDefault</a> and <a>overwrite</a> to construct new <a>ScopeM</a>.
data ScopeM a

-- | Constructor for <a>ScopeM</a>. Values declared by this function are
--   overwritten by same name variables exits in scope of render function.
setDefault :: Ident -> Q Exp -> ScopeM ()

-- | Constructor for <a>ScopeM</a>. Values declared by this function
--   overwrites same name variables exits in scope of render function.
overwrite :: Ident -> Q Exp -> ScopeM ()

-- | Settings that are used when processing heterocephalus templates.
data HeterocephalusSetting
HeterocephalusSetting :: Q Exp -> ParseOptions -> HeterocephalusSetting

-- | Template variables are passed to <a>escapeExp</a> in the output. This
--   allows things like escaping HTML entities. (See <a>htmlSetting</a>.)
[escapeExp] :: HeterocephalusSetting -> Q Exp
[parseOptions] :: HeterocephalusSetting -> ParseOptions

-- | A setting that DOES NOT escape template variables.
--   
--   This sets <a>escapeExp</a> to <a>preEscapedToMarkup</a>.
textSetting :: HeterocephalusSetting

-- | A setting that escapes template variables for Html
--   
--   This sets <a>escapeExp</a> to <a>toHtml</a>.
htmlSetting :: HeterocephalusSetting
data ParseOptions
ParseOptions :: Char -> Char -> ParseOptions
[parseOptionsControlPrefix] :: ParseOptions -> Char
[parseOptionsVariablePrefix] :: ParseOptions -> Char

-- | Default set of parser options.
--   
--   Sets <a>parseOptionsControlPrefix</a> to <tt>'%'</tt> and
--   <a>parseOptionsVariablePrefix</a> to <tt>'#'</tt>.
defaultParseOptions :: ParseOptions
createParseOptions :: Char -> Char -> ParseOptions
type DefaultScope = [(Ident, Q Exp)]
compile :: HeterocephalusSetting -> QuasiQuoter

-- | QuasiQuoter.
compileWith :: ScopeM () -> HeterocephalusSetting -> QuasiQuoter

-- | QuasiQuoter.
compileWithDefault :: DefaultScope -> HeterocephalusSetting -> QuasiQuoter

-- | Compile a template file.
compileFile :: HeterocephalusSetting -> FilePath -> Q Exp

-- | Same as <a>compileFile</a> but we can specify default scope.
compileFileWith :: ScopeM () -> HeterocephalusSetting -> FilePath -> Q Exp

-- | Same as <a>compileFile</a> but we can specify default scope.
compileFileWithDefault :: DefaultScope -> HeterocephalusSetting -> FilePath -> Q Exp

-- | Same as <a>compileFile</a>, but just compile the <a>String</a> given.
--   
--   <pre>
--   &gt;&gt;&gt; let as = ["&lt;a&gt;", "b"]
--   
--   &gt;&gt;&gt; let template = "sample %{ forall a &lt;- as }key: #{a}, %{ endforall }"
--   
--   &gt;&gt;&gt; renderMarkup $(compileFromString textSetting template)
--   "sample key: &lt;a&gt;, key: b, "
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; let as = ["&lt;a&gt;", "b"]
--   
--   &gt;&gt;&gt; let options = createParseOptions '|' '?'
--   
--   &gt;&gt;&gt; let setting = textSetting { parseOptions = options }
--   
--   &gt;&gt;&gt; let template = "sample |{ forall a &lt;- as }key: ?{a}, |{ endforall }"
--   
--   &gt;&gt;&gt; renderMarkup $(compileFromString setting template)
--   "sample key: &lt;a&gt;, key: b, "
--   </pre>
compileFromString :: HeterocephalusSetting -> String -> Q Exp
compileFromStringWithDefault :: DefaultScope -> HeterocephalusSetting -> String -> Q Exp
instance GHC.Show.Show (Text.Heterocephalus.VarExp msg url)
instance GHC.Base.Semigroup (Text.Heterocephalus.ScopeM ())
instance GHC.Base.Monoid (Text.Heterocephalus.ScopeM ())
instance GHC.Base.Functor Text.Heterocephalus.ScopeM
instance GHC.Base.Applicative Text.Heterocephalus.ScopeM
instance GHC.Base.Monad Text.Heterocephalus.ScopeM
instance Data.String.IsString Text.Shakespeare.Base.Ident
