middleman / middleman-sprockets

Sprockets support for Middleman
http://middlemanapp.com
MIT License
62 stars 53 forks source link

NameError: undefined local variable or method `extensions' #111

Closed GSI closed 8 years ago

GSI commented 8 years ago

Middleman 4.1.6 + middleman-sprockets (4.0.0.rc.2)

I am unsure if this is a bug or if I'm just misunderstanding something:

In foo.js.erb I have this: var availabeLanguages = <%= extensions[:i18n].options.langs %>;

When opening http://0.0.0.0:4567/javascripts/foo.js I see this text:

throw Error("NameError: undefined local variable or method `extensions' for #<#<Class:0x005630a336b580>:0x005630a30d4b28>\n  on line 30 of /path/to/source/javascripts/foo.js.erb)")

How may I access extensions (or config) in this context?

tdreyno commented 8 years ago

app.extensions should do the trick.

That said, it does make sense to expose that at extensions in both environment, so I will add that going forward

tdreyno commented 8 years ago

Ah, I see, this is a problem with the Sprockets environment, not Middleman's.

I've exposed extensions in config.

GSI commented 8 years ago

Works like a charm now. Thank you, Thomas.