Permalink
Browse files

Improve comments for addTemplates functions

  • Loading branch information...
1 parent 28b4365 commit 44e9dddd3b05f312e1f024b1da6e1ca3b466f13b @mightybyte mightybyte committed Mar 4, 2012
Showing with 16 additions and 3 deletions.
  1. +6 −2 src/Snap/Snaplet/Heist.hs
  2. +10 −1 src/Snap/Snaplet/HeistNoClass.hs
View
8 src/Snap/Snaplet/Heist.hs
@@ -90,14 +90,18 @@ class HasHeist b where
-- read from the templates directory in the current snaplet's filesystem root.
addTemplates :: HasHeist b
=> ByteString
- -- ^ Path to templates (also the url prefix for their routes)
+ -- ^ The url prefix for the template routes
-> Initializer b v ()
addTemplates pfx = withTop' heistLens (Unclassed.addTemplates pfx)
------------------------------------------------------------------------------
-- | 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
=> ByteString
-- ^ URL prefix for template routes
View
11 src/Snap/Snaplet/HeistNoClass.hs
@@ -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
- -- ^ Path to templates (also the url prefix for their routes)
+ -- ^ The url prefix for the template routes
-> Initializer b (Heist b) ()
addTemplates urlPrefix = do
snapletPath <- getSnapletFilePath
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
-- ^ URL prefix for template routes
-> FilePath

0 comments on commit 44e9ddd

Please sign in to comment.