我有一个简单的Yesod项目,其目录结构通常如下所示:
./Main.hs
./Foundation.hs
./Handler/Home.hs
./Handler/... etc
./config/routes
./templates/home.hamlet
./templates/default-layout.hamlet
./templates/default-layout-wrapper.hamlet
./templates/default-layout-wrapper.cassius
...我试图用堆栈构建这个项目,通常情况下,Main.hs程序位于app目录下。
我尝试将所有的Yesod结构放在app dir下( app dir是上面的. )。
该项目的阴谋文件如下所示:
executable proj-web01-exe
hs-source-dirs: app
main-is: Main.hs
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends: base, bytestring, split, filepath
, stm, data-default, text, conduit, conduit-extra
, containers, resourcet, blaze-html, blaze-markup
, shakespeare, yesod, yesod-static
, proj-web01
default-language: Haskell2010现在,当我尝试stack build时,我得到以下错误消息:
[1 of 6] Compiling Foundation ( app/Foundation.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/proj-web01-exe/proj-web01-exe-tmp/Foundation.o )
/home/me/proj-web01/app/Foundation.hs:46:35:
Exception when trying to run compile-time code:
Called widgetFileNoReload on "default-layout", but no templates were found.
Code: widgetFileNoReload (def) "default-layout"
In the splice: $(widgetFileNoReload def "default-layout")
-- While building package proj-web01-0.1.0.0 using:
/home/me/.stack/setup-exe-cache/x86_64-linux/setup-Simple-Cabal-1.22.5.0-ghc-7.10.3 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.22.5.0 build lib:proj-web01 exe:proj-web01-exe --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1widgetFileNoReload不知道在哪里可以找到app/templates目录中的“默认布局”文件。
我的问题:是应该以不同的方式编写阴谋文件,还是应该放置模板,Handler.其他地方的文件夹(如src)?使用堆栈时最自然的目录结构是什么?或者如何设置堆栈参数(cabal和yaml文件)以适应通常的Yesod目录结构?
发布于 2016-01-13 14:08:55
如果您采用标准的Yesod脚手架,它应该可以编译,而不是Stack (事实上,我现在正在这样做)。我建议不要移动脚手架文件,直到您熟悉设置。如果您真的想移动源文件,我建议将模板保留在原来的位置。
https://stackoverflow.com/questions/34764371
复制相似问题