From c5841f762d2f254bc38ff50b5241a9d6fd6bfb28 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Sun, 11 Apr 2010 23:23:29 -0700 Subject: [PATCH] Fixed hellotemplate example --- examples/hellotemplate.lhs | 25 ++++++++++++++----------- examples/helloworld.lhs | 1 - 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/examples/hellotemplate.lhs b/examples/hellotemplate.lhs index 3e8d9c7c..ead588f3 100644 --- a/examples/hellotemplate.lhs +++ b/examples/hellotemplate.lhs @@ -1,29 +1,32 @@ \begin{code} {-# LANGUAGE QuasiQuotes #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TypeFamilies #-} import Yesod import Network.Wai.Handler.SimpleServer data HelloWorld = HelloWorld TemplateGroup + +mkYesod "HelloWorld" [$parseRoutes| +/ Home GET +/groups Group GET +|] + +instance Yesod HelloWorld where + approot _ = "http://localhost:3000" instance YesodTemplate HelloWorld where getTemplateGroup (HelloWorld tg) = tg defaultTemplateAttribs _ _ = return . setHtmlAttrib "default" "" -instance Yesod HelloWorld where - resources = [$mkResources| -/: - Get: helloWorld -/groups: - Get: helloGroup -|] -helloWorld :: Handler HelloWorld RepHtml -helloWorld = templateHtml "template" $ return +getHome :: Handler HelloWorld RepHtml +getHome = templateHtml "template" $ return . setHtmlAttrib "title" "Hello world!" . setHtmlAttrib "content" "Hey look!! I'm !" -helloGroup :: YesodTemplate y => Handler y RepHtmlJson -helloGroup = templateHtmlJson "real-template" (cs "bar") $ \ho -> +getGroup :: YesodTemplate y => Handler y RepHtmlJson +getGroup = templateHtmlJson "real-template" (cs "bar") $ \ho -> return . setHtmlAttrib "foo" ho main :: IO () diff --git a/examples/helloworld.lhs b/examples/helloworld.lhs index beb022ca..f7111808 100644 --- a/examples/helloworld.lhs +++ b/examples/helloworld.lhs @@ -5,7 +5,6 @@ import Yesod import Network.Wai.Handler.SimpleServer -import qualified Web.Routes.Quasi data HelloWorld = HelloWorld