Created
July 21, 2009 17:31
-
-
Save cmoore/151477 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
-- | |
-- 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