Creating filter for Stylus CSS

84 views
Skip to first unread message

Matias

unread,
Feb 6, 2012, 7:31:01 AM2/6/12
to nanoc
Hi all,

I have tried to create a filter for Stylus CSS (http://
lucasmazza.github.com/ruby-stylus/), but without luck. I have modified
config.yaml to include 'styl' in the text_extensions list, I have
created Gemfile, and I have installed bundler.

Below is code for /lib/stylus.rb

require 'stylus'
class StylusFilter < Nanoc3::Filter
identifier :stylus
def run(content, params = {})
Stylus.compile(content, :compress => true)
end
end

The problem lies in the Rules file. I tried many things, none of them
worked and now the file is all messed up. x) Where can I find the
original (unmodified) Rules file?

Also, where should I place my .styl files? In the content folder?

Thanks for any help!

Cheers,
Matias

Matias

unread,
Feb 7, 2012, 5:00:51 AM2/7/12
to nanoc
> Where can I find the
> original (unmodified) Rules file?

I can get it by creating a new nanoc site, of course. P:

But I still can't figure out what to write in the Rules file. Ouch.

justin

unread,
Feb 7, 2012, 9:53:40 AM2/7/12
to na...@googlegroups.com
Here's an excerpt from my Rules file (it's for handling .less files,
but it'll be basically the same:

```
# stylesheets
route '/css/style/' do
'/css/style.css'
end
compile '/css/style/' do
filter :less
filter :rainpress
end
route '/css/*' do
nil
end
compile '/css/*' do
nil
end
```

I put all my stylesheets in content/css/

Note that I'm excluding all files in content/css/ other than
`style.less` (nil route, nil compile). This is because my stylesheet
has imports and magick, and I don't need to compile all the partials
as well. You'll prob'ly use something like this if you're using
partials. The catchall `*` rule needs to come after the more specific
inclusions, otherwise the exclusion rule will win.

-- justin

> --
> You received this message because you are subscribed to the nanoc discusssion group.
>
> To post to this group, send email to na...@googlegroups.com
> To unsubscribe from this group, send email to
> nanoc+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nanoc?hl=en

--
http://justinhileman.com

Reply all
Reply to author
Forward
0 new messages