11
我目前正在通過遵循tutorial on the Yesod Wiki來實驗Yesod。鏈接到哈姆雷特的一個靜態文件
首先,我創建了使用yesod init
一個耶索德應用程序,並創建了渲染稱作homepage
一個widget文件根處理程序:
getRootR = do
mu <- maybeAuth
defaultLayout $ do
h2id <- lift newIdent
setTitle "Home"
addWidget $(widgetFile "homepage")
我在靜態目錄呼叫static/img/logo.png
觸摸後的圖像文件Settings/staticFiles.hs
,我成功地管理通過
<img [email protected]{StaticR img_logo_png}
從
default-layout.hamlet
該文件鏈接
現在的問題是,我想使用完全相同的代碼行將此靜態文件包含在我的homepage
小部件中。在編譯時會出現以下錯誤:
Handler/Root.hs:19:21:
Not in scope: `img_logo_png'
In the result of the splice:
$(widgetFile "homepage")
To see what the splice expanded to, use -ddump-splices
In the first argument of `addWidget', namely
`$(widgetFile "homepage")'
In the expression: addWidget ($(widgetFile "homepage"))
所以我的問題是:我怎麼與widgetFile
定義的小部件鏈接的靜態資源,爲什麼它會表現不同的默認佈局模板?