[web-devel] [Yesod] Nesting widgets

Aren Olson reacocard at gmail.com
Mon Jun 6 19:59:13 CEST 2011

On Mon, Jun 6, 2011 at 12:37, Michael Snoyman <michael at snoyman.com> wrote:
> Sorry for a terse reply, but the trick is to replace addHamlet with
> addWidget, and the original code should work. Let me know if you're
> still having trouble, I should have more time to respond next week.

I'm not sure how addWidget helps with nesting, as it's just 'id'
internally, right? So what I'd get out of it is still the same Widget
type as what addHamlet was giving, which doesn't interpolate via ^{}
as can be demonstrated with this example:

blockW :: Widget () -> Widget ()
blockW contents = do
    addHamlet [hamlet|

However, if I add an extractBody on contents to pull out the body
tags, then it works:

blockW :: Widget () -> Widget ()
blockW contents = do
    body <- extractBody contents
    addHamlet [hamlet|

It'd certainly make sense to me that using contents directly here
should work, but it clearly isn't at the moment so I am using
extractBody to get around that.


More information about the web-devel mailing list