From 0874b61763bba1fc27adf1b7dc1221e507989511 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Wed, 19 Jan 2011 21:53:39 +0200 Subject: [PATCH] Recent Hamlet changes --- Yesod/Core.hs | 90 ++++++++++++++++++++++++----------------------- Yesod/Internal.hs | 6 ++-- yesod-core.cabal | 2 +- 3 files changed, 51 insertions(+), 47 deletions(-) diff --git a/Yesod/Core.hs b/Yesod/Core.hs index 78a1f40e..2dc122e8 100644 --- a/Yesod/Core.hs +++ b/Yesod/Core.hs @@ -116,16 +116,17 @@ class Eq (Route a) => Yesod a where defaultLayout w = do p <- widgetToPageContent w mmsg <- getMessage - hamletToRepHtml [HAMLET| -!!! -%html - %head - %title $pageTitle.p$ - ^pageHead.p^ - %body - $maybe mmsg msg - %p.message $msg$ - ^pageBody.p^ + hamletToRepHtml [HAMLET|\ +\ + + + + #{pageTitle p} + \^{pageHead p} + <body> + $maybe msg <- mmsg + <p .message>#{msg} + \^{pageBody p} |] -- | Gets called at the beginning of each request. Useful for logging. @@ -306,8 +307,8 @@ defaultErrorHandler NotFound = do #else [$hamlet| #endif -%h1 Not Found -%p $path'$ +<h1>Not Found +<p>#{path'} |] defaultErrorHandler (PermissionDenied msg) = applyLayout' "Permission Denied" @@ -316,8 +317,8 @@ defaultErrorHandler (PermissionDenied msg) = #else [$hamlet| #endif -%h1 Permission denied -%p $msg$ +<h1>Permission denied +<p>#{msg} |] defaultErrorHandler (InvalidArgs ia) = applyLayout' "Invalid Arguments" @@ -326,10 +327,10 @@ defaultErrorHandler (InvalidArgs ia) = #else [$hamlet| #endif -%h1 Invalid Arguments -%ul - $forall ia msg - %li $msg$ +<h1>Invalid Arguments +<ul> + $forall msg <- ia + <li>#{msg} |] defaultErrorHandler (InternalError e) = applyLayout' "Internal Server Error" @@ -338,8 +339,8 @@ defaultErrorHandler (InternalError e) = #else [$hamlet| #endif -%h1 Internal Server Error -%p $e$ +<h1>Internal Server Error +<p>#{e} |] defaultErrorHandler (BadMethod m) = applyLayout' "Bad Method" @@ -348,8 +349,8 @@ defaultErrorHandler (BadMethod m) = #else [$hamlet| #endif -%h1 Method Not Supported -%p Method "$m$" not supported +<h1>Method Not Supported +<p>Method "#{m}" not supported |] -- | Return the same URL if the user is authorized to see it. @@ -418,21 +419,21 @@ widgetToPageContent (GWidget w) = do #else [$hamlet| #endif -$forall scripts s - %script!src=^s^ -$forall stylesheets s - %link!rel=stylesheet!href=^s^ -$maybe style s - $maybe cssLoc s - %link!rel=stylesheet!href=$s$ +$forall s <- scripts + <script src="^{s}"> +$forall s <- stylesheets + <link rel="stylesheet" href="^{s}"> +$maybe s <- style + $maybe s <- cssLoc + <link rel="stylesheet" href="#{s}"> $nothing - %style ^celper.s^ -$maybe jscript j - $maybe jsLoc s - %script!src=$s$ + <style>^{celper s} +$maybe j <- jscript + $maybe s <- jsLoc + <script src="#{s}"> $nothing - %script ^jelper.j^ -^head'^ + <script>^{jelper j} +\^{head'} |] return $ PageContent title head'' body @@ -500,15 +501,16 @@ redirectToPost dest = hamletToRepHtml #else [$hamlet| #endif -!!! -%html - %head - %title Redirecting... - %body!onload="document.getElementById('form').submit()" - %form#form!method=post!action=@dest@ - %noscript - %p Javascript has been disabled; please click on the button below to be redirected. - %input!type=submit!value=Continue +\<!DOCTYPE html> + +<html> + <head> + <title>Redirecting... + <body onload="document.getElementById('form').submit()"> + <form id="form" method="post" action="@{dest}"> + <noscript> + <p>Javascript has been disabled; please click on the button below to be redirected. + <input type="submit" value="Continue"> |] >>= sendResponse yesodVersion :: String diff --git a/Yesod/Internal.hs b/Yesod/Internal.hs index 20a1cc28..1880260c 100644 --- a/Yesod/Internal.hs +++ b/Yesod/Internal.hs @@ -70,8 +70,10 @@ langKey = "_LANG" data Location url = Local url | Remote String deriving (Show, Eq) locationToHamlet :: Location url -> Hamlet url -locationToHamlet (Local url) = [HAMLET|@url@|] -locationToHamlet (Remote s) = [HAMLET|$s$|] +locationToHamlet (Local url) = [HAMLET|\@{url} +|] +locationToHamlet (Remote s) = [HAMLET|\#{s} +|] newtype UniqueList x = UniqueList ([x] -> [x]) instance Monoid (UniqueList x) where diff --git a/yesod-core.cabal b/yesod-core.cabal index 3038df4d..2979f520 100644 --- a/yesod-core.cabal +++ b/yesod-core.cabal @@ -47,7 +47,7 @@ library , monad-peel >= 0.1 && < 0.2 , enumerator >= 0.4 && < 0.5 , cookie >= 0.0 && < 0.1 - , blaze-html >= 0.3.2.1 && < 0.4 + , blaze-html >= 0.4 && < 0.5 exposed-modules: Yesod.Content Yesod.Core Yesod.Dispatch