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