Skip to content

Commit

Permalink
Improve comments for addTemplates functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mightybyte committed Mar 4, 2012
1 parent 28b4365 commit 44e9ddd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/Snap/Snaplet/Heist.hs
Expand Up @@ -90,14 +90,18 @@ class HasHeist b where
-- read from the templates directory in the current snaplet's filesystem root. -- read from the templates directory in the current snaplet's filesystem root.
addTemplates :: HasHeist b addTemplates :: HasHeist b
=> ByteString => ByteString
-- ^ Path to templates (also the url prefix for their routes) -- ^ The url prefix for the template routes
-> Initializer b v () -> Initializer b v ()
addTemplates pfx = withTop' heistLens (Unclassed.addTemplates pfx) addTemplates pfx = withTop' heistLens (Unclassed.addTemplates pfx)




------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- | Adds templates to the Heist HeistState, and lets you specify where -- | Adds templates to the Heist HeistState, and lets you specify where
-- they are found in the filesystem. -- they are found in the filesystem. Note that the path to the template
-- directory is an absolute path. This allows you more flexibility in where
-- your templates are located, but means that you have to explicitly call
-- getSnapletFilePath if you want your snaplet to use templates within its
-- normal directory structure.
addTemplatesAt :: HasHeist b addTemplatesAt :: HasHeist b
=> ByteString => ByteString
-- ^ URL prefix for template routes -- ^ URL prefix for template routes
Expand Down
11 changes: 10 additions & 1 deletion src/Snap/Snaplet/HeistNoClass.hs
Expand Up @@ -266,15 +266,24 @@ heistInitWorker templateDir initialHeistState = do




------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- | Adds templates to the Heist HeistState. Other snaplets should use
-- this function to add their own templates. The templates are automatically
-- read from the templates directory in the current snaplet's filesystem root.
addTemplates :: ByteString addTemplates :: ByteString
-- ^ Path to templates (also the url prefix for their routes) -- ^ The url prefix for the template routes
-> Initializer b (Heist b) () -> Initializer b (Heist b) ()
addTemplates urlPrefix = do addTemplates urlPrefix = do
snapletPath <- getSnapletFilePath snapletPath <- getSnapletFilePath
addTemplatesAt urlPrefix (snapletPath </> "templates") addTemplatesAt urlPrefix (snapletPath </> "templates")




------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- | Adds templates to the Heist HeistState, and lets you specify where
-- they are found in the filesystem. Note that the path to the template
-- directory is an absolute path. This allows you more flexibility in where
-- your templates are located, but means that you have to explicitly call
-- getSnapletFilePath if you want your snaplet to use templates within its
-- normal directory structure.
addTemplatesAt :: ByteString addTemplatesAt :: ByteString
-- ^ URL prefix for template routes -- ^ URL prefix for template routes
-> FilePath -> FilePath
Expand Down

0 comments on commit 44e9ddd

Please sign in to comment.