hastache-0.2.1: Haskell implementation of Mustache templates

Text.Hastache

Description

Haskell implementation of Mustache templates

See homepage for examples of usage: http://github.com/lymar/hastache

Simplest example:

module Main where 

import Text.Hastache 
import Text.Hastache.Context 
import qualified Data.ByteString.Lazy as LZ 

main = do 
    res <- hastacheStr defaultConfig (encodeStr template)  
        (mkStrContext context) 
    LZ.putStrLn res 
    where 
    template = "Hello, {{name}}!" 
    context "name" = MuVariable "Haskell"

Result:

Hello, Haskell!

Synopsis

Documentation

hastacheStrSource

Arguments

:: MonadIO m 
=> MuConfig

Configuration

-> ByteString

Template

-> MuContext m

Context

-> m ByteString 

Render Hastache template from ByteString

hastacheFileSource

Arguments

:: MonadIO m 
=> MuConfig

Configuration

-> FilePath

Template file name

-> MuContext m

Context

-> m ByteString 

Render Hastache template from file

hastacheStrBuilderSource

Arguments

:: MonadIO m 
=> MuConfig

Configuration

-> ByteString

Template

-> MuContext m

Context

-> m Builder 

Render Hastache template from ByteString

hastacheFileBuilderSource

Arguments

:: MonadIO m 
=> MuConfig

Configuration

-> FilePath

Template file name

-> MuContext m

Context

-> m Builder 

Render Hastache template from file

type MuContext mSource

Arguments

 = ByteString

Variable name

-> MuType m

Value

Data for Hastache variable

data MuType m Source

Constructors

forall a . MuVar a => MuVariable a 
MuList [MuContext m] 
MuBool Bool 
forall a . MuVar a => MuLambda (ByteString -> a) 
forall a . MuVar a => MuLambdaM (ByteString -> m a) 
MuNothing 

Instances

Show (MuType m) 

data MuConfig Source

Constructors

MuConfig 

Fields

muEscapeFunc :: ByteString -> ByteString

Escape function (htmlEscape, emptyEscape etc.)

muTemplateFileDir :: Maybe FilePath

Directory for search partial templates ({{> templateName}})

muTemplateFileExt :: Maybe String

Partial template files extension

htmlEscape :: ByteString -> ByteStringSource

Escape HTML symbols

defaultConfig :: MuConfigSource

Default config: HTML escape function, current directory as template directory, template file extension not specified

encodeStr :: String -> ByteStringSource

Convert String to UTF-8 Bytestring

encodeStrLBS :: String -> ByteStringSource

Convert String to UTF-8 Lazy Bytestring

decodeStr :: ByteString -> StringSource

Convert UTF-8 Bytestring to String

decodeStrLBS :: ByteString -> StringSource

Convert UTF-8 Lazy Bytestring to String