Skip to content

Instantly share code, notes, and snippets.

@ErinCall
Last active Aug 29, 2015
Embed
What would you like to do?
Simple site that doesn't actually run its splice
<!DOCTYPE html>
<html>
<head></head>
<body>
<currentPath/>
</body>
</html>
<!DOCTYPE html>
<html>
<head></head>
<body>
<currentPath></currentPath>
</body>
</html>
{-# LANGUAGE OverloadedStrings #-}
------------------------------------------------------------------------------
module Site
( app
) where
------------------------------------------------------------------------------
import Data.Monoid
import Snap.Snaplet
import Snap.Snaplet.Heist
import Heist
------------------------------------------------------------------------------
import Application
import Splices
------------------------------------------------------------------------------
-- | The application initializer.
app :: SnapletInit App App
app = makeSnaplet "andrewlorente" "My wubsite" Nothing $ do
let config = mempty {
hcInterpretedSplices = "currentPath" ## currentPath
}
h <- nestSnaplet "heist" heist $ heistInit' "templates" config
return $ App h
module Splices where
import Application
import Control.Monad.Trans.Class (lift)
import Snap.Snaplet.Heist
import Snap.Core
import Data.Text.Encoding (decodeUtf8)
import qualified Text.XmlHtml as X
currentPath :: SnapletISplice App
currentPath = do
requestPath <- lift $ withRequest (return . rqURI)
return [X.TextNode $ decodeUtf8 requestPath]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment