2011-07-03 51 views
4

我想在Yesod中使用Blueprint CSS框架。有没有最佳做法?如何在Yesod中使用CSS框架?

因为Yesod使用CSS模板,它在我看来我不能直接使用.css文件?我必须将它们重命名为.lucius-files吗?

如何将CSS添加到defaultLayout?

回答

6

一种方法是将其重命名为.lucius文件,其中应该完美工作。 (如果没有,这是Lucius中的一个错误,你应该报告它。)但是,你也可以将CSS存储在静态文件夹中,并用addStylesheet调用引用它;例如,这是我使用Yesod Wiki所采用的方法。

+0

在CSS框架的情况下,看起来最好的做法是将它们放在静态文件夹中。 – davidbe

4

对此,yesod wiki有一个article。该解决方案基本上是把蓝图的副本在你的静态文件夹中,那么您可以在一个类型安全的方式参考蓝图是这样的(在你的templates/default-layout-wrapper.hamlet^{pageHead pc}前):

<link rel=stylesheet media=screen [email protected]{StaticR blueprint_screen_css}> 
<link rel=stylesheet media=print [email protected]{StaticR blueprint_print_css}> 
+0

链接到文章似乎被打破。 – interstar

+0

对不起@interstar。我现在更新了链接。 :) – Tarrasch