<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Grails Geek &#187; CSS convention</title>
	<atom:link href="http://grailsgeek.com/tag/css-convention/feed/" rel="self" type="application/rss+xml" />
	<link>http://grailsgeek.com</link>
	<description>Grails tips I wanna share with you ;)</description>
	<lastBuildDate>Sun, 01 Nov 2009 13:29:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>CSS convention for Grails</title>
		<link>http://grailsgeek.com/2009/07/css-convention-for-grails/</link>
		<comments>http://grailsgeek.com/2009/07/css-convention-for-grails/#comments</comments>
		<pubDate>Sun, 26 Jul 2009 15:58:16 +0000</pubDate>
		<dc:creator>Alexander Naumenko</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[CSS convention]]></category>
		<category><![CDATA[grails]]></category>

		<guid isPermaLink="false">http://grailsgeek.com/?p=43</guid>
		<description><![CDATA[As far as our CSS styles grow I found that there should intuitive way to manage CSS inclusions. I&#8217;ve decided to follow great Grails fundamental idea and place them by some convention and include automagically.
We found useful to have separate CSS for each view (or controller action if you wish). Convention is simple: place each [...]]]></description>
			<content:encoded><![CDATA[<p>As far as our CSS styles grow I found that there should intuitive way to manage CSS inclusions. I&#8217;ve decided to follow great Grails fundamental idea and place them by some convention and include automagically.</p>
<p>We found useful to have separate CSS for each view (or controller action if you wish). Convention is simple: place each CSS in the same path as you place your views under <span style="color: #333399;">/views</span> folder.</p>
<p>For example, we have view: <span style="color: #333399;">/views/picture/gallery.gsp</span> and want to have <span style="color: #333399;">gallery.css</span> which contains all styles for this view. We should place it in the same path as our view located, in our example it should be <span style="color: #333399;">/web-app/css/picture/gallery.css</span>. Now to automatically include such CSSs by convention we should modify our main layout (<span style="color: #333399;">/views/layouts/main.gsp</span>) next way:</p>
<pre class="brush:groovy">&lt;head&gt;
...
&lt;% if (webRequest.controllerName &amp;&amp; webRequest.actionName) { %&gt;
    &lt;link rel="stylesheet" href="${resource(dir: 'css/' + webRequest.getControllerName(), file: webRequest.getActionName() + '.css')}"/&gt;
&lt;% } %&gt;
...
&lt;/head&gt;</pre>
<p>All further CSSs placed by this convention will be automatically included for each action (which uses <span style="color: #333399;">main</span> layout) . If you have more layouts you could modify them same way. Anyway their count will be much less than your actions/views count.</p>
<p>Hope this helps. If you have some ideas to improve this approach or you use some other approach, please share :)</p>
<pre></pre>
]]></content:encoded>
			<wfw:commentRss>http://grailsgeek.com/2009/07/css-convention-for-grails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
