我创建了一个简单的yesod应用程序,并希望覆盖默认布局。
可以在Yesod实例的Foundation.hs文件中将其覆盖,如下所示:
instance Yesod App where
defaultLayout :: Widget -> Handler Html
defaultLayout widget = ([whamlet|<p>This is my page. I hope you enjoyed it.</p>|])
--do
-- master <- getYesod
-- mmsg <- getMessage
-- mcurrentRoute <- getCurrentRoute
-- -- Get the breadcrumbs, as defined in the YesodBreadcrumbs instance.
-- (title, parents) <- breadcrumbs
-- -- Define the menu items of the header.
-- let menuItems =
-- [ NavbarLeft $ MenuItem
-- { menuItemLabel = "Home"
-- , menuItemRoute = HomeR
-- , menuItemAccessCallback = True
-- }
-- ]
-- let navbarLeftMenuItems = [x | NavbarLeft x <- menuItems]
-- let navbarRightMenuItems = [x | NavbarRight x <- menuItems]
-- let navbarLeftFilteredMenuItems = [x | x <- navbarLeftMenuItems, menuItemAccessCallback x]
-- let navbarRightFilteredMenuItems = [x | x <- navbarRightMenuItems, menuItemAccessCallback x]
-- -- We break up the default layout into two components:
-- -- default-layout is the contents of the body tag, and
-- -- default-layout-wrapper is the entire page. Since the final
-- -- value passed to hamletToRepHtml cannot be a widget, this allows
-- -- you to use normal widget features in default-layout.
-- pc <- widgetToPageContent $ do
-- addStylesheet $ StaticR css_bootstrap_css
-- $(widgetFile "default-layout")
-- withUrlRenderer $(hamletFile "templates/default-layout-wrapper.hamlet")
如您所见,我试图用简单的文本输出覆盖,但是不会进行编译。编译器抱怨:
A section must be enclosed in parentheses
thus: (whamlet |< p > This is my page . I hope you enjoyed it .</ p
>|)
|
88 | defaultLayout widget = [whamlet|<p>This is my page. I hope you enjoyed it.</p>|]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
我的目标是提供一个空白页。
如何发送简单的空白页?