Sass asset handling broken?

8 views
Skip to first unread message

Rob Emerson

unread,
Sep 23, 2008, 3:16:48 PM9/23/08
to na...@googlegroups.com
Attempting to create a Sass-based asset from tutorial/bare 'create_site'.

I get this issue:

ERROR: An exception occured while compiling /bar/ (rep default).

If you think this is a bug in nanoc, please do report it at
<http://nanoc.stoneship.org/trac/newticket> -- thanks!

Message:
Error: undefined method `attribute_named' for nil:NilClass

Compilation stack:
- [asset] /bar/ (rep default)

Backtrace:
-
/var/lib/gems/1.8/gems/nanoc-2.1.2/bin/../lib/nanoc/filters/sass.rb:10:in
`run'
-
/var/lib/gems/1.8/gems/nanoc-2.1.2/bin/../lib/nanoc/base/asset_rep.rb:266:in
`compile_textual'
-
/var/lib/gems/1.8/gems/nanoc-2.1.2/bin/../lib/nanoc/base/asset_rep.rb:258:in
`each'
-
/var/lib/gems/1.8/gems/nanoc-2.1.2/bin/../lib/nanoc/base/asset_rep.rb:258:in
`compile_textual'
-
/var/lib/gems/1.8/gems/nanoc-2.1.2/bin/../lib/nanoc/base/asset_rep.rb:193:in
`compile'
-
/var/lib/gems/1.8/gems/nanoc-2.1.2/bin/../lib/nanoc/base/compiler.rb:61:in
`run'
-
/var/lib/gems/1.8/gems/nanoc-2.1.2/bin/../lib/nanoc/base/compiler.rb:57:in
`each'
-
/var/lib/gems/1.8/gems/nanoc-2.1.2/bin/../lib/nanoc/base/compiler.rb:57:in
`run'
-
/var/lib/gems/1.8/gems/nanoc-2.1.2/bin/../lib/nanoc/cli/commands/compile.rb:74:in
`run'
-
/var/lib/gems/1.8/gems/nanoc-2.1.2/bin/../lib/nanoc/cli/base.rb:84:in `run'
- /var/lib/gems/1.8/gems/nanoc-2.1.2/bin/nanoc:12
- /var/lib/gems/1.8/bin/nanoc:18:in `load'
- /var/lib/gems/1.8/bin/nanoc:18


Steps to reproduce:

1) Create a new nanoc site e.g. 'nanoc create_site foo'

2) Create a directory under assets e.g. 'bar'

3) Create two files under assets/bar e.g. bar.sass and bar.yaml

4) bar.sass is empty

5) bar.yaml contains:

cat bar.yaml
binary: false
filters: [ 'sass' ]

It seems for some reason, nanoc isn't finding the asset representation
properly and so passing through a Nil PageRep which is causing the issue
here.

Where am I going wrong? Am I missing some attributes/config here? I can
see the sample sites use asset handling for plain CSS but not Sass.

Many thanks in advance for any pointers!

Cheers,

Rob

Denis Defreyne

unread,
Sep 24, 2008, 12:17:16 PM9/24/08
to na...@googlegroups.com
On 23 Sep 2008, at 21:16, Rob Emerson wrote:

>
> Attempting to create a Sass-based asset from tutorial/bare
> 'create_site'.
>
> I get this issue:
>
> ERROR: An exception occured while compiling /bar/ (rep default).
>
> If you think this is a bug in nanoc, please do report it at
> <http://nanoc.stoneship.org/trac/newticket> -- thanks!
>
> Message:
> Error: undefined method `attribute_named' for nil:NilClass
>

> [..]


>
> It seems for some reason, nanoc isn't finding the asset representation
> properly and so passing through a Nil PageRep which is causing the
> issue
> here.

This is a bug in nanoc which will be fixed shortly.

The cause for this bug is that the Sass (and Haml) filters get their
Haml/Sass options by doing something along the lines of
options = @page_rep.attribute_named(:haml_options) || {}
which should actually be
options = @obj_rep.attribute_named(:haml_options) || {}
(i.e. @obj_rep instead of @page_rep). This makes sense because
@page_rep is nil if the file is an asset, and @asset_rep is nil when
the file is a page. @obj_rep is never nil (and neither is @obj, which
can be a page or an asset).

You can override Nanoc::Filters::Sass#run in your own site to make
sure it uses @obj_rep instead of @page_rep. I'll be pushing the
changes to Hg and releasing an update once all this has been tested.

Regards,

Denis

--
Denis Defreyne
denis.d...@stoneship.org

Reply all
Reply to author
Forward
0 new messages