-
Notifications
You must be signed in to change notification settings - Fork 374
1.1 upgrade
This is a collection of notes about upgrading to Yesod 1.1. Please feel free to add your own comments.
As usual, the first step to the upgrade process is edit your cabal file to allow Yesod 1.1 and then run cabal install --only-dependencies
. It may also be necessary to pass in the --force-reinstalls
flag.
If you write a blog post describing your upgrade process, please add it here.
Yesod 1.1 includes Hamlet 1.1. In previous versions of Hamlet, there was no automatic whitespace added. That means that, for example:
<p>
hello
world
becomes <p>helloworld</p>
. With Hamlet 1.1, we've made a few changes:
- The default strategy is to add newlines.
- You can now change the newline strategy within the Hamlet template itself with a
$newline
statement. Possible values are:-
$newline always
: Put newlines between consecutive text lines, and between tags. -
$newline text
: Put newlines between consecutive text lines, but not between tags. -
$newline never
: Never put in newlines automatically.
-
Since this change in newline strategy can actually change the behavior of existing code, we've added a warning to any Hamlet template which does not specify the newline strategy. This warning will likely be removed in future versions.
If you're upgrading your site to 1.1, and you're annoyed by all of these newline
warnings, you have two options to get rid of them:
- Add a
$newline
statement to the beginning of each template. Use$newline never
if you want to maintain the behavior of Hamlet 1.0. - Alternatively, you can specify your newline settings in the
widgetFile
settings (see the scaffolded Settings.hs). This will only help for uses ofwidgetFile
, not arbitrary calls towhamlet
orhamlet
. If you really want to get around the warnings for those, you can define local copies of those QQ functions in yourSettings.hs
file that explicitly state a newline setting.
The placement of the $newline
statement is a little sensitive. This doesn't work:
getHomeR = defaultLayout [whamlet|
$newline always
Hello World!
|]
but this does (ie the $newline
needs to be a the very start of the whamlet template):
getHomeR = defaultLayout [whamlet|$newline always
Hello World!
|]