Skip to content

Instantly share code, notes, and snippets.

@cmoore
Created July 21, 2009 17:31
Show Gist options
  • Save cmoore/151477 to your computer and use it in GitHub Desktop.
Save cmoore/151477 to your computer and use it in GitHub Desktop.
--
-- bt spits out a template without any options parsing.
--
bt :: String -> IO Response
bt x = do
templates <- directoryGroup "templates"
return $ def { body = pack $ renderTemplateGroup templates ([]::[(String,String)]) x, status = 200 }
--
-- btt gives a template with the provides options subtituted.
--
-- This would probably make more sense as btt :: String -> [(String,String)] -> IO Response
--
btt :: [(String,String)] -> String -> IO Response
btt blob tmpl = do
templates <- directoryGroup "templates"
return $ def { body = pack $
renderTemplateGroup templates blob tmpl,
status = 200 }
-- liftM Prelude.concat $ option_list [("hugh","Hugh Lowrie"),("fry","Steven Fry")]
option_list :: [(String,String)] -> IO String
option_list b = do
templates <- directoryGroup "templates"
return $ unlines $ map (\(name,text) ->
renderTemplateGroup templates [("name", name),("text",text)] "option" ) b
createSelectBox :: String -> [(String,String)] -> IO String
createSelectBox name opp = do
opt <- option_list opp
templates <- directoryGroup "templates"
return $ renderTemplateGroup templates [("selname",name),("options",opt)] "selector"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment