Last active
August 29, 2015 13:57
-
-
Save ErinCall/9776660 to your computer and use it in GitHub Desktop.
Simple site that doesn't actually run its splice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head></head> | |
<body> | |
<currentPath/> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head></head> | |
<body> | |
<currentPath></currentPath> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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