私は現在、tutorial on the Yesod Wikiに従ってYesodを試しています。Hamletの静的ファイルへのリンク
まず私はyesod init
を使用してイェソドアプリケーションを作成し、ウィジェットファイルをレンダリングするルートハンドラを作成したがhomepage
と呼ばれる:
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}
経由でリンクできました
この静的なファイルを、同じコード行を使用して私の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
で定義されたウィジェットに静的リソースをリンクする、そしてなぜそれがデフォルトのレイアウトテンプレートで異なる動作をしますか?