问题描述:

I have a Yesod 0.9.3 scaffolded site with some small fragments that are different for every page, such as styles for specific id attributes generated from an undetermined number of search results, and I want to place them in <style> or <script> tags in the <head> of the page, so that they do not pollute my /static/tmp (while the rest of the lucius/julius templates is placed in generated files, resulting in a dozen such files for the whole site).

addJulius and addLucius include their content to one common .js or .css file (at least for Lucius) which is generated according to its content.

Is there any way to do so, more straightforward than this?

toWidgetHead [hamlet| <style> ##{someIdent} { some: style; } |]

This ends up in the generated file, not in a style tag inside page:

toWidgetHead [lucius| ##{someIdent} { some: style; } |]

网友答案:

The function addStaticContent can control this. just set it to return Nothing in the cases where you want the assets to be embedded in the html file.

addStaticContent haddocks

相关阅读:
Top