Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix bug in flashCSplice

  • Loading branch information...
commit 5daf8e8e5119a186cbd1f4e2c4cfb4ac885a28ce 1 parent 557ea18
@mightybyte mightybyte authored
Showing with 28 additions and 27 deletions.
  1. +28 −27 src/Snap/Extras/FlashNotice.hs
View
55 src/Snap/Extras/FlashNotice.hs
@@ -72,17 +72,17 @@ flashError session msg = withSession session $ with session $ setInSession "_err
-- Ex: <flash type='success'/>
flashSplice :: SnapletLens b SessionManager -> SnapletISplice b
flashSplice session = do
- typ <- liftM (getAttribute "type") getParamNode
- let typ' = maybe "warning" id typ
- let k = T.concat ["_", typ']
- msg <- lift $ withTop session $ getFromSession k
- case msg of
- Nothing -> return []
- Just msg' -> do
- lift $ withTop session $ deleteFromSession k >> commitSession
- callTemplateWithText "_flash" $ do
- "type" ## typ'
- "message" ## msg'
+ typ <- liftM (getAttribute "type") getParamNode
+ let typ' = maybe "warning" id typ
+ let k = T.concat ["_", typ']
+ msg <- lift $ withTop session $ getFromSession k
+ case msg of
+ Nothing -> return []
+ Just msg' -> do
+ lift $ withTop session $ deleteFromSession k >> commitSession
+ callTemplateWithText "_flash" $ do
+ "type" ## typ'
+ "message" ## msg'
-------------------------------------------------------------------------------
@@ -95,21 +95,22 @@ flashCSplice session = do
n <- getParamNode
let typ = maybe "warning" id $ getAttribute "type" n
k = T.concat ["_", typ]
- splice getVal = do
- let ss = do
- "type" ## return $ C.yieldPureText typ
- "message" ## return $ C.yieldRuntimeText $ liftM fromJust
- $ getVal
- flashTemplate <- C.withLocalSplices ss
- noSplices (C.callTemplate "_flash")
- return $ C.yieldRuntime $ do
- msg <- getVal
- case msg of
- Nothing -> return mempty
- Just _ -> do
- lift $ withTop session $
- deleteFromSession k >> commitSession
- C.codeGen flashTemplate
- splice (lift $ withTop session $ getFromSession k)
+ getVal = lift $ withTop session $ getFromSession k
+ ss = do
+ "type" ## return $ C.yieldPureText typ
+ "message" ## return $ C.yieldRuntimeText
+ $ liftM (fromMaybe "Flash notice cookie error")
+ getVal
+ flashTemplate <- C.withLocalSplices ss noSplices (C.callTemplate "_flash")
+ return $ C.yieldRuntime $ do
+ msg <- getVal
+ case msg of
+ Nothing -> return mempty
+ Just _ -> do
+ res <- C.codeGen flashTemplate
+ lift $ withTop session $ do
+ deleteFromSession k
+ commitSession
+ return res
Please sign in to comment.
Something went wrong with that request. Please try again.