首页 > 解决方案 > 如何传递一个空白页面?

问题描述

我创建了一个简单的 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>|]
   |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  

我的目标是提供一个空白页面。

如何交付一个简单的空白页面?

标签: haskellyesod

解决方案


推荐阅读