Created
June 13, 2013 13:20
-
-
Save xkikeg/5773600 to your computer and use it in GitHub Desktop.
Yesod Book :: Shakespearean Templates :: simple interpolation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- 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