Copyright | (c) digitally induced GmbH 2021 |
---|---|
Safe Haskell | None |
IHP.PageTitle.ViewFunctions
Description
Synopsis
- pageTitle :: (?context :: ControllerContext) => Text
- pageTitleOrDefault :: (?context :: ControllerContext) => Text -> Text
- pageTitleOrNothing :: (?context :: ControllerContext) => Maybe Text
- module IHP.PageTitle.ControllerFunctions
Documentation
pageTitle :: (?context :: ControllerContext) => Text Source #
Returns the current page title. The title can be set using setTitle "my title"
from the action.
If the title hasn't been set yet, this will return an empty string. You can also use pageTitleOrDefault
to pass a custom default title.
You can use this inside your title
tag like this:
[hsx| <head> <title>{pageTitle}</title> </head> |]
- App-wide default title:*
You can set a app-wide default title by calling setTitle
from the FrontController.hs
:
instance InitControllerContext Web where initContext = do setLayout defaultLayout initAutoRefresh setTitle "Jobs"
- View-specific title:*
You can set a custom title inside the view by calling setTitle
inside the beforeRender
hook.
module JobSite.View.JobPositions.Show where instance View ShowView where beforeRender ShowView { .. } = do setTitle "Custom title" html ShowView { .. } = [hsx|..|]
pageTitleOrDefault :: (?context :: ControllerContext) => Text -> Text Source #
pageTitleOrNothing :: (?context :: ControllerContext) => Maybe Text Source #
Returns the current page title or Nothing if not set yet
Re-export as we want to call setTitle from the beforeRender hook