css_dryer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.autotest ADDED
@@ -0,0 +1,8 @@
1
+ global_autotest_file = File.expand_path('~/.autotest')
2
+ load(global_autotest_file) if File.exists?(global_autotest_file)
3
+
4
+ class Autotest
5
+ def tests_for_file(filename)
6
+ Dir['test/**/*_test.rb']
7
+ end
8
+ end
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ pkg/
2
+ Gemfile.lock
data/CHANGELOG ADDED
@@ -0,0 +1,129 @@
1
+ = Change Log
2
+
3
+ Below is a complete list of changes for each revision of CssDryer.
4
+
5
+ == 0.4.3
6
+
7
+ * Rake task to generate CSS from nested stylesheets "off-line".
8
+
9
+ == 0.4.2
10
+
11
+ * Rails 2.3.2 and Ruby 1.9 support (thanks David Balatero).
12
+
13
+ == 0.4.1
14
+
15
+ * Rack support.
16
+ * Updated test nested stylesheet to render a partial and call a helper.
17
+
18
+ == 0.4.0
19
+
20
+ * Refactored file layout so tests run again.
21
+
22
+ == 0.3.1
23
+
24
+ * Merged Mina Guib's refactoring of the template handling code. Partials now work again. Thanks Mina!
25
+
26
+ == 0.3.0
27
+
28
+ * Rails 2.2 compatibility (thanks to Josh Peek for help).
29
+ * The self_clear helper accepts a :clear option.
30
+
31
+ == 0.2.8
32
+
33
+ * Fixed bug in Stylesheets Helper affecting ie6 method (thanks to René).
34
+ * Removed code in +render+ method made redundant by Rails 2.1.
35
+
36
+ == 0.2.7
37
+
38
+ * Rails 2.1 compatibility (thanks to Pete Yandell).
39
+
40
+ == 0.2.6
41
+
42
+ * Added a few browser hacks to StylesheetsHelper (thanks to René for the idea).
43
+ * Add self-clearing to StylesheetsHelper.
44
+ * Added test that reproduces bug where css_dryer forgives missing closing brace. Just need to make it pass :-)
45
+ * Added section on StylesheetsHelper to README.
46
+
47
+ == 0.2.5
48
+
49
+ * Added a generator for convenience.
50
+
51
+ == 0.2.4
52
+
53
+ * Fixed README to use proper Markdown syntax for links.
54
+
55
+ == 0.2.3
56
+
57
+ * Fixed typo in NcssHandler#render (reported by Ryan Kuykendall).
58
+
59
+ == 0.2.2
60
+
61
+ * Removed compilation step because it doesn't allow post-processing.
62
+
63
+ == 0.2.1
64
+
65
+ * Fixed typo with name of NcssHandler's compile method.
66
+ * Elaborated README's partials example.
67
+
68
+ == 0.2.0
69
+
70
+ * Supports partial templates.
71
+ * Works with Rails's template compilation mechanism.
72
+ * Requires Rails 2.
73
+
74
+ == 0.1.5
75
+
76
+ * Achieved compatibility with Markaby by adding filepath paramater to template rendering (NcssHandler#render) method signature (incompatibility reported by Ray Carrasco).
77
+
78
+ == 0.1.4
79
+
80
+ * Commas in comments are sometimes replaced with a space to prevent them from being interpreted as selectors (thanks to Adrian Prodan for the bug report). Yes, this is a shameful hack.
81
+ * Added tests for multiline comments and comments containing blank lines (suggested by Phil Crosby).
82
+ * Added a section on how comments are handled to the README.
83
+ * Removed page_cache_extension line from the StylesheetsController code. It was unnecessary and forced all cached pages, including HTML ones, to have a .css extension.
84
+
85
+ == 0.1.3
86
+
87
+ * Instance and local variables from the controller now available within stylesheets (thanks to Rifraf for prodding me into action).
88
+
89
+ == 0.1.2
90
+
91
+ * Incompatible with Rails 1.1.6 and below thanks to the use of <code>:format</code> in a route. Update to Rails 1.2RC1 :)
92
+ * Caches correctly with <code>.css</code> extension. Updated the README with the necessary changes to the controller and routes.
93
+ * Works with the <code>stylesheet_link_tag</code> helper. Updated the README with the changes to make this work.
94
+
95
+ == 0.1.1
96
+
97
+ * Fixed bug where comma separated style values, e.g. font families, were misinterpreted as comma separated selectors.
98
+
99
+ == 0.1.0
100
+
101
+ * Handles comma separated selectors (suggested by John Nunemaker).
102
+ * No longer outputs nested blank lines (noticed by Adi).
103
+
104
+ == 0.0.5
105
+
106
+ * Changed extension from <code>.dcss</code> to <code>.ncss</code> to avoid clashing with Miles Byrne's DCSS stylesheets (suggested by Miles).
107
+ * Clarified the lack of support for nested, multiple, comma separated selectors by adding a paragraph to the README's Which Selectors Are Supported section.
108
+
109
+ == 0.0.4
110
+
111
+ * Handles class, pseudo-class, attribute, id, child and adjacent selectors (suggested by Adi and Maxim Kulkin).
112
+ * No longer outputs empty selectors (noticed by Adi).
113
+ * Fixed typo in nesting example in README.
114
+
115
+ == 0.0.3
116
+
117
+ * Fixed bug where parameter was passed to the wrong method.
118
+
119
+ == 0.0.2
120
+
121
+ * Added support for <code>@media</code> blocks.
122
+ * Fixed bug in handling of non-nested descendant selectors.
123
+ * Handles whitespace consistently, preserving the original as much as possible.
124
+
125
+ == 0.0.1
126
+
127
+ * Initial public release.
128
+ * Handles descendant selectors.
129
+ * Handles ERB.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/MIT-LICENCE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2006 Andrew Stewart
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,273 @@
1
+ # CssDryer -- Eliminate Repetition In Your Stylesheets
2
+
3
+ *Please note I am no longer working on this. I'm pleased to say it was the first and, for a long time, the only Rails plugin to support nested selectors. It did the job admirably but now I use [SASS](http://sass-lang.com/) instead.*
4
+
5
+
6
+ ## Introduction
7
+
8
+ Cascading style sheets (CSS) are wonderful but repetitive. [Repetition is bad](http://en.wikipedia.org/wiki/Don't_repeat_yourself), so CssDryer lets you write CSS without repeating yourself. And you don't need to learn any new syntax.
9
+
10
+ There are two sources of repetition in CSS:
11
+
12
+ * nested selectors
13
+ * lack of variables
14
+
15
+ Nested selectors lead to CSS like this:
16
+
17
+ div { font-family: Verdana; }
18
+ div#content { background-color: green; }
19
+ div#content p { color: red; }
20
+
21
+ Note the triple repetition of `div` and the double repetition of `#content`.
22
+
23
+ The lack of variables leads to CSS like this:
24
+
25
+ .sidebar { border: 1px solid #fefefe; }
26
+ .content { color: #fefefe; }
27
+
28
+ Note the repeated colour `#fefefe`.
29
+
30
+ CssDryer eliminates both of these. The examples above become:
31
+
32
+ <% dark_grey = '#fefefe' %>
33
+
34
+ div {
35
+ font-family: Verdana;
36
+ #content {
37
+ background-color: green;
38
+ p { color: red; }
39
+ }
40
+ }
41
+
42
+ .sidebar { border: 1 px solid <%= dark_grey %>; }
43
+ .content { color: <%= dark_grey %>; }
44
+
45
+ Note, though, that `@media` blocks are preserved. For example:
46
+
47
+ @media screen, projection {
48
+ div {font-size:100%;}
49
+ }
50
+
51
+ is left unchanged.
52
+
53
+ The original whitespace is preserved as much as possible.
54
+
55
+
56
+ ## Which Selectors Are Supported?
57
+
58
+ CssDryer handles all [CSS 2.1 selectors](http://www.w3.org/TR/CSS21/selector.html): nested descendant, child, adjacent, class, pseudo-class, attribute and id selectors.
59
+
60
+ Multiple comma separated selectors are also supported.
61
+
62
+
63
+ ## Comments
64
+
65
+ Comments on nested selectors do not get 'flattened' or de-nested with their selector. For example comment B will be left inside the html selector below:
66
+
67
+ Before:
68
+
69
+ /* Comment A */
70
+ html {
71
+ /* Comment B */
72
+ p {
73
+ color: blue;
74
+ }
75
+ }
76
+
77
+ After:
78
+
79
+ /* Comment A */
80
+ html {
81
+ /* Comment B */
82
+ }
83
+ html p {
84
+ color: blue;
85
+ }
86
+
87
+ This is suboptimal but I hope not too inconvenient.
88
+
89
+ Please also note that commas in comments will sometimes be replaced with a space. This is due to a shameful hack in the code that handles comma-separated selectors.
90
+
91
+
92
+ ## Partials
93
+
94
+ You may use partial nested stylesheets as you would with normal templates. For example, assuming your controller(s) set the @user variable and a User has a background colour (red):
95
+
96
+ app/views/stylesheets/site.css.ncss:
97
+
98
+ body {
99
+ color: blue;
100
+ <%= render :partial => 'content', :locals => {:background => @user.background} %>
101
+ }
102
+
103
+ app/views/stylesheets/_content.css.ncss:
104
+
105
+ div#content {
106
+ background: <%= background %>;
107
+ margin: 10px;
108
+ }
109
+
110
+ And all this would render to `site.css`:
111
+
112
+ body {
113
+ color: blue;
114
+ }
115
+ body div#content {
116
+ background: red;
117
+ margin: 10px;
118
+ }
119
+
120
+
121
+ ## Remember the helper
122
+
123
+ Browser hacks are an ugly necessity in any non-trivial stylesheet. They clutter up your stylesheet without actually adding anything. They make you sad.
124
+
125
+ So encapsulate them in the StylesheetsHelper instead. Separate your lovely CSS from the decidely unlovely hacks. For example:
126
+
127
+ app/views/stylesheets/site.css.ncss:
128
+
129
+ <% ie7 do %>
130
+ #sidebar {
131
+ padding: 4px;
132
+ }
133
+ <% end %>
134
+
135
+ This renders to `site.css`:
136
+
137
+ *+html #sidebar {
138
+ padding: 4px;
139
+ }
140
+
141
+ In this example the hacky selector, `*+html`, isn't too bad. However some hacks are pretty long-winded, and soon you'll thank yourself for moving them out of your nested stylesheet.
142
+
143
+ You don't have to limit yourself to browser hacks. Consider self-clearing: to make an element clear itself requires 13 lines of CSS, in 3 selector blocks, by my count. To make a second element clear itself, you need to add the element's selector to each of those three blocks. It's fiddly. And your stylesheet gets harder and harder to understand.
144
+
145
+ We can do better:
146
+
147
+ app/views/stylesheets/site.css.ncss:
148
+
149
+ <%= self_clear 'div.foo', 'div.bar', 'baz' %>
150
+
151
+ Self-clear as many elements as you like in one easy line.
152
+
153
+
154
+ ## Installation
155
+
156
+ ### Rails plugin
157
+
158
+ Pre-requisite: Rails 2.3.
159
+
160
+ First, install in the usual Rails way. From your application's directory:
161
+
162
+ $ script/plugin install git://github.com/airblade/css_dryer.git
163
+
164
+ Second, generate the stylesheets controller and helper, and a test nested stylesheet:
165
+
166
+ $ script/generate css_dryer
167
+
168
+ Third, add a named route to your `config/routes.rb`:
169
+
170
+ map.stylesheets 'stylesheets/:action.:format', :controller => 'stylesheets'
171
+
172
+ Verify that everything is working by visiting this URL:
173
+
174
+ http://0.0.0.0:3000/stylesheets/test.css
175
+
176
+ You should see this output:
177
+
178
+ body {
179
+ color: blue;
180
+ }
181
+ body p {
182
+ color: red;
183
+ }
184
+ h4 {
185
+ color: red;
186
+ }
187
+ h4 em { font-weight: bold; }
188
+ * + html h2 {
189
+ margin-top: 1em;
190
+ }
191
+
192
+ If the output looks good, delete `app/views/stylesheets/{test,_foo}.css.ncss`.
193
+
194
+ ### Rack
195
+
196
+ See the example `config.ru` file. I'm a beginner with Rack so feedback would be much appreciated.
197
+
198
+
199
+ ## Usage
200
+
201
+ You put your stylesheets, DRY or otherwise, in `app/views/stylesheets/`. Once rendered they will be cached in `public/stylesheets/`.
202
+
203
+ DRY stylesheet files should have a `ncss` extension -- think 'n' for nested. For example, `site.css.ncss`.
204
+
205
+ Get them in your views with a `css` extension like this:
206
+
207
+ <link href='/stylesheets/site.css' rel='Stylesheet' type='text/css'>
208
+
209
+ or with Rails' `stylesheet_link_tag` helper:
210
+
211
+ <%= stylesheet_link_tag 'site' %>
212
+
213
+
214
+ ## Caching, Rake and Capistrano
215
+
216
+ By default the CSS rendered from your nested stylesheets is page-cached by Rails when caching is on (in production). However there are two disadvantages:
217
+
218
+ * You can't bundle these stylesheets into a single file (`stylesheet_link_tag :all, :cache => true`).
219
+ * Rails' `stylesheet_link_tag` helper won't append a timestamp to the CSS path. This means you cannot invalidate any browsers' caches of your stylesheet. If you update your stylesheet, client web browsers will not see the update until they hard-reset their cache.
220
+
221
+ We can solve both these problems by pre-generating our CSS files from our nested stylesheets every time we deploy. Rails will then just see normal CSS files and the bundling and cache-busting behaviour will work again.
222
+
223
+ The rake task `css_dryer:to_css` will convert your nested stylesheets into CSS files. Use the following Capistrano code to get your servers to do this on each deploy:
224
+
225
+ namespace :deploy do
226
+ task :after_update_code do
227
+ generate_css
228
+ end
229
+
230
+ task :generate_css, :roles => [:web] do
231
+ run "cd #{release_path}; RAILS_ROOT=#{release_path} rake css_dryer:to_css"
232
+ end
233
+ end
234
+
235
+ Note: this bypasses Rails so you can't do it if your nested stylesheets use instance variables from your controller.
236
+
237
+
238
+ ## Alternatives
239
+
240
+ * [Less CSS][less]: on top of the variables and nested rules that css_dryer offers, Less provides mixins and operations. This is a popular project under active development.
241
+
242
+ * [Sass][sass]: variables, nested rules, mixins and more, all using a pared-down syntax. From the creators of HAML.
243
+
244
+
245
+ ## Credits
246
+
247
+ The idea came from John Nunemaker on [Rails Tips][railstips]. John beta-tested the code, provided a test case for @media blocks and suggested the controller's body. Thanks John!
248
+
249
+
250
+ ## To Do
251
+
252
+ * Configuration, e.g. `#implicit_nested_divs = true`
253
+ * Package as a gem as well as a plugin.
254
+ * Replace regexp-based nested-stylesheet parser with a Treetop parser.
255
+
256
+
257
+ ## Author
258
+
259
+ [Andrew Stewart][aws], [AirBlade Software Ltd][airblade].
260
+
261
+
262
+ ## Licence
263
+
264
+ CssDryer is available under the MIT licence. See MIT-LICENCE for the details.
265
+
266
+ Copyright (c) 2006-2010 Andrew Stewart
267
+
268
+
269
+ [less]: http://lesscss.org
270
+ [sass]: http://sass-lang.com
271
+ [railstips]: http://railstips.org/2006/12/7/styleaby-css-plugin/
272
+ [aws]: mailto:boss@airbladesoftware.com
273
+ [airblade]: http://airbladesoftware.com
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+ require 'rdoc/task'
5
+
6
+ desc 'Default: run unit tests.'
7
+ task :default => :test
8
+
9
+ desc 'Test the css_dryer plugin.'
10
+ Rake::TestTask.new(:test) do |t|
11
+ t.libs << 'lib'
12
+ t.pattern = 'test/**/*_test.rb'
13
+ t.verbose = true
14
+ end
15
+
16
+ desc 'Generate documentation for the css_dryer plugin.'
17
+ Rake::RDocTask.new(:rdoc) do |rdoc|
18
+ rdoc.rdoc_dir = 'rdoc'
19
+ rdoc.title = 'CssDryer'
20
+ rdoc.options << '--line-numbers' << '--inline-source'
21
+ rdoc.rdoc_files.include('README')
22
+ rdoc.rdoc_files.include('lib/**/*.rb')
23
+ end
data/config.ru ADDED
@@ -0,0 +1,14 @@
1
+ # An example Rackup file.
2
+
3
+ require 'rubygems'
4
+ require 'rack'
5
+ require 'lib/rack/css_dryer'
6
+
7
+ use Rack::CssDryer
8
+
9
+ theapp = Proc.new { |env|
10
+ content = '<h1>Hi!</h1>'
11
+ [200, {'Content-Type' => 'text/html', 'Content-Length' => content.length.to_s}, content]
12
+ }
13
+
14
+ run theapp
data/css_dryer.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = "css_dryer"
5
+ gem.version = "0.0.1"
6
+ gem.authors = ["Andrew Stewart", "Peter Suschlik"]
7
+ gem.email = ["boss@airbladesoftware.com", "ps@neopoly.de"]
8
+ gem.description = %q{[Deprecated] The first CSS pre-processor for Rails 2.3}
9
+ gem.summary = %q{Cascading style sheets (CSS) are wonderful but repetitive. Repetition is bad, so CssDryer lets you write CSS without repeating yourself. And you don't need to learn any new syntax.}
10
+ gem.homepage = "https://github.com/neopoly/css_drayer"
11
+
12
+ gem.files = `git ls-files`.split($/)
13
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
+ gem.require_paths = ["lib"]
16
+
17
+ gem.add_development_dependency 'rake'
18
+ gem.add_development_dependency 'rdoc'
19
+ end
@@ -0,0 +1,11 @@
1
+ Description:
2
+ Generates the supporting code for your nested stylesheets, and a test nested stylesheet.
3
+
4
+ Example:
5
+ ./script/generate css_dryer
6
+
7
+ This will create:
8
+ app/controllers/stylesheets_controller.rb
9
+ app/helpers/stylesheets_helper.rb
10
+ app/views/test.css.ncss
11
+ app/views/_foo.css.ncss
@@ -0,0 +1,23 @@
1
+ class CssDryerGenerator < Rails::Generator::Base
2
+ def manifest
3
+ record do |m|
4
+ m.file 'stylesheets_controller.rb',
5
+ 'app/controllers/stylesheets_controller.rb',
6
+ :chmod => 0644,
7
+ :collision => :ask
8
+ m.file 'stylesheets_helper.rb',
9
+ 'app/helpers/stylesheets_helper.rb',
10
+ :chmod => 0644,
11
+ :collision => :skip
12
+ m.directory 'app/views/stylesheets'
13
+ m.file 'test.css.ncss',
14
+ 'app/views/stylesheets/test.css.ncss',
15
+ :chmod => 0644,
16
+ :collision => :skip
17
+ m.file '_foo.css.ncss',
18
+ 'app/views/stylesheets/_foo.css.ncss',
19
+ :chmod => 0644,
20
+ :collision => :skip
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,4 @@
1
+ h4 {
2
+ color: <%= bar %>;
3
+ em { font-weight: bold; }
4
+ }
@@ -0,0 +1,11 @@
1
+ class StylesheetsController < ApplicationController
2
+ before_filter :set_headers
3
+ after_filter { |controller| controller.cache_page }
4
+ layout nil
5
+
6
+ private
7
+
8
+ def set_headers
9
+ headers['Content-Type'] = 'text/css; charset=utf-8'
10
+ end
11
+ end
@@ -0,0 +1,63 @@
1
+ module StylesheetsHelper
2
+
3
+ # Internet Exploder hacks.
4
+
5
+ # <% ie6 do %>
6
+ # css for ie6 here
7
+ # <% end %>
8
+ def ie6(&block)
9
+ wrap '* html', &block
10
+ end
11
+
12
+ # <% ie7 do %>
13
+ # css for ie7 here
14
+ # <% end %>
15
+ def ie7(&block)
16
+ wrap '* + html', &block
17
+ end
18
+
19
+ # Self-clearing. For example:
20
+ #
21
+ # <%= self_clear 'div#foo', 'img.bar', 'p ul' %>
22
+ #
23
+ # You can pass a hash as the final argument with these options:
24
+ # :clear => 'left' | 'right' | 'both' (default)
25
+ def self_clear(*selectors)
26
+ options = selectors.extract_options!
27
+ clear = options[:clear] || 'both'
28
+
29
+ selector_template = lambda { |proc| selectors.map{ |s| proc.call s }.join ', ' }
30
+
31
+ p = lambda { |selector| "#{selector}:after" }
32
+ q = lambda { |selector| "* html #{selector}" }
33
+ r = lambda { |selector| "*:first-child+html #{selector}" }
34
+
35
+ <<-END
36
+ #{selector_template.call p} {
37
+ content: ".";
38
+ display: block;
39
+ height: 0;
40
+ clear: #{clear};
41
+ visibility: hidden;
42
+ }
43
+ #{selector_template.call q} {
44
+ height: 1%;
45
+ }
46
+ #{selector_template.call r} {
47
+ min-height: 1px;
48
+ }
49
+ END
50
+ end
51
+
52
+
53
+ private
54
+
55
+ # Wraps the block's output with +with+ and braces.
56
+ # css_dryer will then de-nest the result when it
57
+ # post-processes the result of the ERB evaluation.
58
+ def wrap(with, &block)
59
+ @output_buffer << "#{with} {"
60
+ yield
61
+ @output_buffer << '}'
62
+ end
63
+ end
@@ -0,0 +1,12 @@
1
+ body {
2
+ color: blue;
3
+ p {
4
+ color: red;
5
+ }
6
+ }
7
+ <%= render :partial => 'foo', :locals => {:bar => 'red'} %>
8
+ <% ie7 do %>
9
+ h2 {
10
+ margin-top: 1em;
11
+ }
12
+ <% end %>
data/init.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'css_dryer/processor'
2
+ require 'css_dryer/ncss_handler'
3
+
4
+ # Register our template handler with Rails.
5
+ ActionView::Template.register_template_handler :ncss, CssDryer::NcssHandler
data/install.rb ADDED
@@ -0,0 +1,3 @@
1
+ # Print installation section of README.
2
+ readme = IO.read(File.join(File.dirname(__FILE__), 'README.markdown'))
3
+ puts readme[/(## Installation.*?)##/m, 1]
@@ -0,0 +1,18 @@
1
+ # Handler for DRY stylesheets which can be registered with Rails
2
+ # as a new templating system.
3
+ #
4
+ # DRY stylesheets are piped through ERB and then CssDryer#process.
5
+ module CssDryer
6
+
7
+ class NcssHandler < ActionView::TemplateHandlers::ERB
8
+ include CssDryer::Processor
9
+ # In case user doesn't have helper or hasn't run generator yet.
10
+ include StylesheetsHelper rescue nil
11
+
12
+ def compile(template)
13
+ temp = super
14
+ temp + "; @output_buffer = CssDryer::NcssHandler.new.process(@output_buffer)"
15
+ end
16
+ end
17
+
18
+ end