Clone this wiki locally
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
If you write a blog post describing your upgrade process, please add it here.
Warning: default newline style has changed, using an explicit $newline is recommended
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
<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
$newlinestatement. 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
$newlinestatement to the beginning of each template. Use
$newline neverif you want to maintain the behavior of Hamlet 1.0.
- Alternatively, you can specify your newline settings in the
widgetFilesettings (see the scaffolded Settings.hs). This will only help for uses of
widgetFile, not arbitrary calls to
hamlet. If you really want to get around the warnings for those, you can define local copies of those QQ functions in your
Settings.hsfile 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! |]