I have a Yesod widget which loads a widget twice. The "main" widget looks like:
<div .container-fluid .hidden-xs>
<div .row .no-gutter>
<div .col-sm-3>
<!-- sidebar content -->
<div .col-sm-9>
<!-- the widget i'm loading twice -->
^{dashboardMain}
<nav .visible-xs>
<!-- sidebar content, also loaded twice, but this widget isn't causing problems (yet) -->
<div .container .visible-xs>
<div .row .no-gutter>
^{dashboardMain}
I am running into problems because the Julius file for my dashboardMain
argument is getting loaded and compiled twice. Yesod is concatenating two copies of my Julius file together. This is breaking things elsewhere.
My Haskell code looks like:
crmSidebar :: Widget
crmSidebar = defaultSidebarItems -- Using Knockout and a convention based "api"
crmApp :: Widget
crmApp = $(widgetFile "app/crm")
getCRMDashboardR :: Handler TypedContent
getCRMDashboardR = selectRep . provideRep . defaultLayout $ dashboardLayout crmSidebarItems crmApp
The Haskell compiles fine, but like I said, I am getting a runtime Javascript error because of how Yesod/Julius is processing my widget. What should I do?
Edit 1:
I'm using KnockoutJS, which requires ko.applyBindings(viewModel)
to be applied exactly once. Changing that isn't an option.
dashboardLayout
is defined by
dashboardLayout :: String -> Widget -> Widget -> Widget
dashboardLayout sidebarHeader dashboardSidebarItems dashboardMain = $(widgetFile "layouts/dashboard")