8
blazehtml教程和其他博客文章非常清楚如何讓字符串文字工作。我明白了。但是,如何獲得字符串(字節串,Data.Text等也可以)。一般來說,元素的屬性/內容。 Blazehtml看起來不錯,但沒有那個,它看起來很沒用。 = P如何將字符串(不是字符串文字)轉換爲blazehtml屬性/元素內容?
這裏的樣本輸出和代碼顯示確切的問題:
{-# LANGUAGE OverloadedStrings #-}
import Prelude
import qualified Prelude as P
import Text.Blaze.Html5
import Text.Blaze.Html5.Attributes
import qualified Text.Blaze.Html5 as H
import qualified Text.Blaze.Html5.Attributes as A
makeLink dest cont = renderHtml $ a ! src dest $ cont
*Main> let foo = "foo" *Main> let bar = "bar" *Main> makeLink foo bar :1:9: Couldn't match expected type `AttributeValue' against inferred type `[Char]' In the first argument of `makeLink', namely `foo' In the expression: makeLink foo bar In the definition of `it': it = makeLink foo bar
函數'stringValue'現在已被棄用。而是使用'Text.Blaze.toValue :: a - > AttributeValue' – 2011-12-29 12:13:48