我试图有一个动态的HTML id,用于调制解调器的使用。
基本上,如果哈姆雷特接受像[hamlet| <div .modal .fade ##{modalIdFunction i}> |]这样的东西,我的问题就会解决。
因为我还没有在哈姆雷特中做到这一点,所以我试着用露西德来做,但这与叶苏德的defaultLayout不相容。
我的目的是:
getSupportR :: CustomerId -> Handler LucidHtml
getSupportR customerId = do
defaultLayout $ do
setTitle "Your Licenses"
toWidget . lucid $ \url ->
p_ $ a_ [href_ "\\"] "Link to root"这是错误消息:
• Couldn't match type ‘blaze-markup-0.8.2.1:Text.Blaze.Internal.MarkupM
()’
with ‘HtmlT Identity ()’
Expected type: HandlerFor App LucidHtml
Actual type: HandlerFor App Html有没有办法把LucidHtml转换成Blaze的Html?
我的全部代码位于:https://github.com/hhefesto/laurus-nobilis,相关文件为/src/Yesod/Lucid.hs和/src/Handler/Support.hs。
发布于 2018-10-30 07:49:01
由于清晰的Html和blaze Html是完全不同的类型,您唯一的方法是将其中一个作为文本呈现,并将其作为预转义的Html插入到另一个文本中。有点像Blaze.preEscapedToHtml . Lucid.renderText。
发布于 2018-10-31 21:32:39
为了完整起见,这是arrowd的答案,它集成到代码中:
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
module Handler.Support where
import Import hiding
import Yesod.Lucid
import Lucid hiding (Html)
import qualified Lucid as L
import Text.Blaze.Html
getSupportR :: CustomerId -> Handler Html
getSupportR customerId = do
lucidHtml <- lucid $ \url ->
p_ $ a_ [href_ "\\"] "link to root"
defaultLayout $ do
setTitle "Your Licenses"
toWidget . preEscapedToHtml . renderText $ lucidHtmlhttps://stackoverflow.com/questions/53055515
复制相似问题