Skip to content

Instantly share code, notes, and snippets.

@ErinCall
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ErinCall/9776660 to your computer and use it in GitHub Desktop.
Save ErinCall/9776660 to your computer and use it in GitHub Desktop.
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