Skip to content

Instantly share code, notes, and snippets.

@xkikeg
Created June 13, 2013 13:20
Show Gist options
  • Select an option

  • Save xkikeg/5773600 to your computer and use it in GitHub Desktop.

Select an option

Save xkikeg/5773600 to your computer and use it in GitHub Desktop.
Yesod Book :: Shakespearean Templates :: simple interpolation
-- Just ignore the quasiquote stuff for now, and that shamlet thing.
-- It will be explained later.
{-# LANGUAGE QuasiQuotes #-}
import Text.Hamlet (shamlet)
import Text.Blaze.Html.Renderer.String (renderHtml)
import Data.Char (toLower)
import Data.List (sort)
data Person = Person
{ name :: String
, age :: Int
}
main :: IO ()
main = putStrLn $ renderHtml [shamlet|
<p>Hello, my name is #{name person} and I am #{show $ age person}.
<p>
Let's do some funny stuff with my name: #
<b>#{sort $ map toLower (name person)}
<p>Oh, and in 5 years I'll be #{show ((+) 5 (age person))} years old.
|]
where
person = Person "Michael" 26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment