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


-- | Haskell implementation of Mustache templates
--   
--   Haskell implementation of Mustache templates
--   (<a>http://mustache.github.com/</a>).
--   
--   See homepage for examples of usage:
--   <a>http://github.com/lymar/hastache</a>
@package hastache
@version 0.3.3


-- | Haskell implementation of Mustache templates
--   
--   See homepage for examples of usage:
--   <a>http://github.com/lymar/hastache</a>
--   
--   Simplest example:
--   
--   <pre>
--   import Text.Hastache 
--   import Text.Hastache.Context 
--   import qualified Data.ByteString.Lazy as LZ 
--   
--   main = do 
--       res &lt;- hastacheStr defaultConfig (encodeStr template)  
--           (mkStrContext context) 
--       LZ.putStrLn res 
--       where 
--       template = "Hello, {{name}}!\n\nYou have {{unread}} unread messages." 
--       context "name" = MuVariable "Haskell"
--       context "unread" = MuVariable (100 :: Int)
--   </pre>
--   
--   Result:
--   
--   <pre>
--   Hello, Haskell!
--   
--   You have 100 unread messages.
--   </pre>
--   
--   Using Generics:
--   
--   <pre>
--   import Text.Hastache 
--   import Text.Hastache.Context 
--   import qualified Data.ByteString.Lazy as LZ 
--   import Data.Data 
--   import Data.Generics 
--   
--   data Info = Info { 
--       name    :: String, 
--       unread  :: Int 
--       } deriving (Data, Typeable)
--   
--   main = do 
--       res &lt;- hastacheStr defaultConfig (encodeStr template) 
--           (mkGenericContext inf) 
--       LZ.putStrLn res 
--       where 
--       template = "Hello, {{name}}!\n\nYou have {{unread}} unread messages."
--       inf = Info "Haskell" 100
--   </pre>
module Text.Hastache

-- | Render Hastache template from ByteString
hastacheStr :: MonadIO m => MuConfig -> ByteString -> MuContext m -> m ByteString

-- | Render Hastache template from file
hastacheFile :: MonadIO m => MuConfig -> FilePath -> MuContext m -> m ByteString

-- | Render Hastache template from ByteString
hastacheStrBuilder :: MonadIO m => MuConfig -> ByteString -> MuContext m -> m Builder

-- | Render Hastache template from file
hastacheFileBuilder :: MonadIO m => MuConfig -> FilePath -> MuContext m -> m Builder

-- | Data for Hastache variable
type MuContext m = ByteString -> MuType m
data MuType m
MuVariable :: a -> MuType m
MuList :: [MuContext m] -> MuType m
MuBool :: Bool -> MuType m
MuLambda :: (ByteString -> a) -> MuType m
MuLambdaM :: (ByteString -> m a) -> MuType m
MuNothing :: MuType m
data MuConfig
MuConfig :: (ByteString -> ByteString) -> Maybe FilePath -> Maybe String -> MuConfig

-- | Escape function (<a>htmlEscape</a>, <a>emptyEscape</a> etc.)
muEscapeFunc :: MuConfig -> ByteString -> ByteString

-- | Directory for search partial templates ({{&gt; templateName}})
muTemplateFileDir :: MuConfig -> Maybe FilePath

-- | Partial template files extension
muTemplateFileExt :: MuConfig -> Maybe String
class Show a => MuVar a where isEmpty _ = False
toLByteString :: MuVar a => a -> ByteString
isEmpty :: MuVar a => a -> Bool

-- | Escape HTML symbols
htmlEscape :: ByteString -> ByteString

-- | No escape
emptyEscape :: ByteString -> ByteString

-- | Default config: HTML escape function, current directory as template
--   directory, template file extension not specified
defaultConfig :: MuConfig

-- | Convert String to UTF-8 Bytestring
encodeStr :: String -> ByteString

-- | Convert String to UTF-8 Lazy Bytestring
encodeStrLBS :: String -> ByteString

-- | Convert UTF-8 Bytestring to String
decodeStr :: ByteString -> String

-- | Convert UTF-8 Lazy Bytestring to String
decodeStrLBS :: ByteString -> String
instance [incoherent] Show (MuType m)
instance [incoherent] MuVar [Char]
instance [incoherent] MuVar a => MuVar [a]
instance [incoherent] MuVar Char
instance [incoherent] MuVar Text
instance [incoherent] MuVar Text
instance [incoherent] MuVar Word64
instance [incoherent] MuVar Word32
instance [incoherent] MuVar Word16
instance [incoherent] MuVar Word8
instance [incoherent] MuVar Word
instance [incoherent] MuVar Int64
instance [incoherent] MuVar Int32
instance [incoherent] MuVar Int16
instance [incoherent] MuVar Int8
instance [incoherent] MuVar Double
instance [incoherent] MuVar Float
instance [incoherent] MuVar Int
instance [incoherent] MuVar Integer
instance [incoherent] MuVar ByteString
instance [incoherent] MuVar ByteString


-- | Hastache context helpers
module Text.Hastache.Context

-- | Make Hastache context from String -&gt; MuType function
mkStrContext :: Monad m => (String -> MuType m) -> MuContext m

-- | Make Hastache context from Data.Data deriving type
--   
--   Supported field types:
--   
--   <ul>
--   <li>String</li>
--   <li>Char</li>
--   <li>Double</li>
--   <li>Float</li>
--   <li>Int</li>
--   <li>Int8</li>
--   <li>Int16</li>
--   <li>Int32</li>
--   <li>Int64</li>
--   <li>Integer</li>
--   <li>Word</li>
--   <li>Word8</li>
--   <li>Word16</li>
--   <li>Word32</li>
--   <li>Word64</li>
--   <li>Data.ByteString.ByteString</li>
--   <li>Data.ByteString.Lazy.ByteString</li>
--   <li>Data.Text.Text</li>
--   <li>Data.Text.Lazy.Text</li>
--   <li>Bool</li>
--   <li>Data.ByteString.ByteString -&gt; Data.ByteString.ByteString</li>
--   <li>String -&gt; String</li>
--   <li>Data.ByteString.ByteString -&gt;
--   Data.ByteString.Lazy.ByteString</li>
--   <li>MonadIO m =&gt; Data.ByteString.ByteString -&gt; m
--   Data.ByteString.ByteString</li>
--   <li>MonadIO m =&gt; String -&gt; m String</li>
--   <li>MonadIO m =&gt; Data.ByteString.ByteString -&gt; m
--   Data.ByteString.Lazy.ByteString</li>
--   </ul>
--   
--   Example:
--   
--   <pre>
--   import Text.Hastache 
--   import Text.Hastache.Context 
--   import qualified Data.ByteString as B
--   import qualified Data.ByteString.Lazy as LZ 
--   import Data.Data 
--   import Data.Generics 
--   import Data.Char
--   
--   data InternalData = InternalData {
--       someField       :: String,
--       anotherField    :: Int
--       } deriving (Data, Typeable, Show)
--   
--   data Example = Example {
--       stringField             :: String,
--       intField                :: Int,
--       dataField               :: InternalData,
--       simpleListField         :: [String],
--       dataListField           :: [InternalData],
--       stringFunc              :: String -&gt; String,
--       byteStringFunc          :: B.ByteString -&gt; B.ByteString,
--       monadicStringFunc       :: String -&gt; IO String,
--       monadicByteStringFunc   :: B.ByteString -&gt; IO B.ByteString
--       } deriving (Data, Typeable)
--   
--   example = hastacheStr defaultConfig (encodeStr template) 
--       (mkGenericContext context)
--       where
--       template = concat $ map (++ "\n") [
--           "string: {{stringField}}",
--           "int: {{intField}}",
--           "data: {{dataField.someField}}, {{dataField.anotherField}}",
--           "data: {{#dataField}}{{someField}}, {{anotherField}}{{/dataField}}",
--           "simple list: {{#simpleListField}}{{.}} {{/simpleListField}}",
--           "data list:",
--           "{{#dataListField}}",
--           " * {{someField}}, {{anotherField}}. top level var: {{intField}}",
--           "{{/dataListField}}",
--           "{{#stringFunc}}upper{{/stringFunc}}",
--           "{{#byteStringFunc}}reverse{{/byteStringFunc}}",
--           "{{#monadicStringFunc}}upper (monadic){{/monadicStringFunc}}",
--           "{{#monadicByteStringFunc}}reverse (monadic){{/monadicByteStringFunc}}"]
--       context = Example { stringField = "string value", intField = 1, 
--           dataField = InternalData "val" 123, simpleListField = ["a","b","c"],
--           dataListField = [InternalData "aaa" 1, InternalData "bbb" 2],
--           stringFunc = map toUpper,
--           byteStringFunc = B.reverse,
--           monadicStringFunc = return . map toUpper,
--           monadicByteStringFunc = return . B.reverse }
--   
--   main = example &gt;&gt;= LZ.putStrLn
--   </pre>
--   
--   Result:
--   
--   <pre>
--   string: string value 
--   int: 1 
--   data: val, 123 
--   data: val, 123 
--   simple list: a b c  
--   data list: 
--    * aaa, 1. top level var: 1 
--    * bbb, 2. top level var: 1 
--   UPPER 
--   esrever 
--   UPPER (MONADIC)
--   )cidanom( esrever
--   </pre>
mkGenericContext :: (Monad m, Data a, Typeable1 m) => a -> MuContext m
instance Show (TD m)
