[web-devel] [Yesod] Nesting widgets

Aren Olson reacocard at gmail.com
Tue Jun 7 07:18:35 CEST 2011


On Mon, Jun 6, 2011 at 14:42, Michael Snoyman <michael at snoyman.com> wrote:
> On Mon, Jun 6, 2011 at 8:59 PM, Aren Olson <reacocard at gmail.com> wrote:
>> 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|
>> <div
>>    ^{contents}|]
>
> Try replacing addHamlet here with addWidget. This has to do with how
> polymorphic Hamlet is implemented (again, sorry for the terseness).

Ahah, I follow you now, and yes that does work. Thanks!



More information about the web-devel mailing list