Commits

Luke Plant committed ce6f383

Pulled out function for retrieving a template

  • Participants
  • Parent commits aa9f200

Comments (0)

Files changed (1)

src/Blog/Views.hs

              setStatus 404
             ]
 
+-- Templates
+
+get_templates = do
+  templates' <- directoryGroup Settings.template_path
+  return $ setEncoderGroup (show . stringToHtml) templates'
+
+get_template name = do
+  templates <- get_templates
+  return $ fromJust $ getStringTemplate name templates
+
 ---- Views
 
 -- View for the main page
 categoriesView req = do
   cn <- connect
   cats <- getCategories cn
-  templates' <- directoryGroup Settings.template_path
-  let templates = setEncoderGroup (show . stringToHtml) templates'
-  let t = fromJust $ getStringTemplate "categories" templates
+  t <- get_template "categories"
   let categories = [ (c, categoryUrl c) | c <- cats ]
   return $ Just $ standardResponseBS $ render $ t `with` [ setAttribute "categories" categories
                                                          , setAttribute "hasCategories" (not . null $ cats)