如何在Yesod中获取TypeSafe URL到静态资源 [英] How to get a TypeSafe URL to a static resource in Yesod

查看:165
本文介绍了如何在Yesod中获取TypeSafe URL到静态资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人可以告诉我如何获得TypeSafe URL到静态资源。我已将/ static作为子网站提供文件,但我不清楚如何使用类型安全网址从那里引用特定文件。我的想法是,我可以将它们包含在addScript等类似的东西中。



我对Yesod很新颖,但我找不到像这样的例子。 Yesod书或FPComplete教程。

解决方案

类似这样: src = @ {StaticR img_myimage_png}



Yesod查看静态目录,文件名将包含由 _ 。用 _ 替换

I was wondering if someone could tell me how I get a TypeSafe URL to a static resource. I've got "/static" as a subsite serving files, but I'm unclear on how to refer to specific files from there using typesafe URLs. The idea is that I could include them in things like addScript and such.

I am very new to Yesod, but I couldn't find an example like this in either the Yesod book or in the FPComplete tutorials.

解决方案

Something like this: src=@{StaticR img_myimage_png}

Yesod looks inside the static directory and the file name will contain the directory name separated by _. Replace . with _ too.

这篇关于如何在Yesod中获取TypeSafe URL到静态资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆